From 54028de04fd30048cc8abde2a5c43378581bc825 Mon Sep 17 00:00:00 2001 From: day-dreams Date: Sun, 13 Sep 2020 01:49:20 +0800 Subject: [PATCH] dialect/sql/schema: add MigrateOption 'WithForeighKeysDisable' (#748) --- dialect/sql/schema/migrate.go | 22 ++++++++++++++----- entc/gen/internal/bindata.go | 4 ++-- entc/gen/template/migrate/migrate.tmpl | 3 +++ .../integration/config/ent/migrate/migrate.go | 3 +++ .../customid/ent/migrate/migrate.go | 3 +++ entc/integration/ent/migrate/migrate.go | 3 +++ entc/integration/hooks/ent/migrate/migrate.go | 3 +++ .../integration/idtype/ent/migrate/migrate.go | 3 +++ entc/integration/json/ent/migrate/migrate.go | 3 +++ .../migrate/entv1/migrate/migrate.go | 3 +++ .../migrate/entv2/migrate/migrate.go | 3 +++ .../privacy/ent/migrate/migrate.go | 3 +++ .../template/ent/migrate/migrate.go | 3 +++ examples/edgeindex/ent/migrate/migrate.go | 3 +++ examples/entcpkg/ent/migrate/migrate.go | 3 +++ examples/m2m2types/ent/migrate/migrate.go | 3 +++ examples/m2mbidi/ent/migrate/migrate.go | 3 +++ examples/m2mrecur/ent/migrate/migrate.go | 3 +++ examples/o2m2types/ent/migrate/migrate.go | 3 +++ examples/o2mrecur/ent/migrate/migrate.go | 3 +++ examples/o2o2types/ent/migrate/migrate.go | 3 +++ examples/o2obidi/ent/migrate/migrate.go | 3 +++ examples/o2orecur/ent/migrate/migrate.go | 3 +++ examples/start/ent/migrate/migrate.go | 3 +++ examples/traversal/ent/migrate/migrate.go | 3 +++ 25 files changed, 88 insertions(+), 7 deletions(-) diff --git a/dialect/sql/schema/migrate.go b/dialect/sql/schema/migrate.go index a25b54cc6..adb8bff54 100644 --- a/dialect/sql/schema/migrate.go +++ b/dialect/sql/schema/migrate.go @@ -59,14 +59,23 @@ func WithFixture(b bool) MigrateOption { } } +// WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are +// not allowed to use foreigh-key. Defaults to false +func WithForeighKeysDisable(b bool) MigrateOption { + return func(m *Migrate) { + m.disableForeighKeys = b + } +} + // Migrate runs the migrations logic for the SQL dialects. type Migrate struct { sqlDialect - universalID bool // global unique ids. - dropColumns bool // drop deleted columns. - dropIndexes bool // drop deleted indexes. - withFixture bool // with fks rename fixture. - typeRanges []string // types order by their range. + universalID bool // global unique ids. + dropColumns bool // drop deleted columns. + dropIndexes bool // drop deleted indexes. + withFixture bool // with fks rename fixture. + disableForeighKeys bool // do not create foreigh keys + typeRanges []string // types order by their range. } // NewMigrate create a migration structure for the given SQL driver. @@ -119,6 +128,9 @@ func (m *Migrate) Create(ctx context.Context, tables ...*Table) error { func (m *Migrate) create(ctx context.Context, tx dialect.Tx, tables ...*Table) error { for _, t := range tables { m.setupTable(t) + if m.disableForeighKeys { + t.ForeignKeys = nil + } switch exist, err := m.tableExist(ctx, tx, t.Name); { case err != nil: return err diff --git a/entc/gen/internal/bindata.go b/entc/gen/internal/bindata.go index ce2e09775..5366e6ae9 100644 --- a/entc/gen/internal/bindata.go +++ b/entc/gen/internal/bindata.go @@ -986,7 +986,7 @@ func templateMetaTmpl() (*asset, error) { return a, nil } -var _templateMigrateMigrateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x56\x4d\x6f\xdc\x36\x10\x3d\x4b\xbf\x62\xaa\xb6\xe9\x6e\xb0\xa6\x1c\x17\x05\xda\x6d\x7c\x48\x6d\xa7\x58\xa0\x75\x53\x38\x41\x7a\x0c\x97\x1c\x49\x84\x29\x52\x21\x47\xfb\x81\xc5\xfe\xf7\x82\xa4\xb4\x1f\xf9\x40\x7a\x68\x51\x5f\x16\x1e\x0e\xdf\x9b\x37\x6f\x48\x6a\xb7\x2b\x9f\xe6\x37\xb6\xdb\x3a\x55\x37\x04\x57\x97\xcf\x7e\xba\xe8\x1c\x7a\x34\x04\x2f\xb9\xc0\xa5\xb5\x8f\xb0\x30\x82\xc1\x0b\xad\x21\x26\x79\x08\xeb\x6e\x85\x92\xe5\xaf\x1b\xe5\xc1\xdb\xde\x09\x04\x61\x25\x82\xf2\xa0\x95\x40\xe3\x51\x42\x6f\x24\x3a\xa0\x06\xe1\x45\xc7\x45\x83\x70\xc5\x2e\xc7\x55\xa8\x6c\x6f\x64\xae\x4c\x5c\xff\x6d\x71\x73\x77\xff\x70\x07\x95\xd2\x08\x43\xcc\x59\x4b\x20\x95\x43\x41\xd6\x6d\xc1\x56\x40\x27\x64\xe4\x10\x59\xfe\xb4\xdc\xef\xf3\x7c\xb7\x03\x89\x95\x32\x08\x45\xab\x6a\xc7\x09\x0b\x48\xf1\x0b\x58\x2b\x6a\x00\x37\x84\x46\xc2\x37\x50\xbc\xe2\xe2\x91\xd7\x58\x9c\x64\x5e\xec\xf7\x79\xb6\xdb\x01\x61\xdb\x69\x4e\x08\x45\x83\x5c\xa2\x2b\x80\x05\x94\xdd\x0e\xc2\xde\x80\xa7\xda\xce\x3a\x82\x49\x9e\x15\xc2\x1a\xc2\x0d\x15\x79\x56\x54\x2d\x15\x79\x9e\x15\xb5\xa2\xa6\x5f\x32\x61\xdb\xb2\x1a\x1a\x57\xa2\xa1\x52\x2a\xae\x51\xc4\xd4\x2f\xa4\x94\xfe\xbd\x2e\xbd\x68\xb0\xe5\x45\x3e\xcd\xf3\x15\x77\x81\xac\x2c\xe1\xad\xa2\xe6\x57\x6d\x97\x5c\xbf\x31\xea\x7d\x8f\x8b\x5b\xf0\x48\x3e\xf6\xa9\x37\x6a\x85\xce\x73\x0d\x4a\x7a\xb0\x1d\x29\x6b\x3c\x90\x8d\x8b\x49\xa5\xb2\x86\x45\x9c\xc5\xd0\xc4\x94\x15\xcc\x42\xc3\x97\x1a\xe5\x0c\x82\xe1\x87\x6c\x58\x2b\xad\x81\x6b\x6d\x45\xe8\x08\x87\x67\xcf\x9f\x7f\x7f\x05\x8e\x9b\x1a\x23\x50\x65\x93\xb1\x91\xb2\x02\xe4\xa2\x09\x08\x8a\xb6\x30\xa1\x80\x38\x4d\x84\xf7\x96\x10\xa8\xe1\x74\xc6\x2b\xb8\x31\x96\x60\x89\xc0\xbb\x4e\x2b\x94\x60\x0d\xc4\x6d\x3e\x25\x73\xed\x90\xcb\x2d\xe0\x46\x79\x62\x79\xf6\x09\xfd\xd7\x90\x3a\xc5\x3e\x5e\x3b\xb4\xec\xd6\xd9\xee\xc6\xea\xbe\x35\xc7\x76\x49\x67\x3b\x10\x29\x38\x94\xf3\x6f\xf4\x2a\xc2\x5a\x2d\x07\x68\x1f\x21\xa2\x96\x35\x3a\x84\x3e\x9c\x87\xd0\xb4\xa5\xa5\x06\x2a\x85\x5a\x7a\xe0\x46\x02\xca\x1a\x3d\x83\x78\x8e\x24\x56\xbc\xd7\x14\xcd\xab\xb8\xf6\x38\x28\x3f\x91\x71\xa6\xfa\x18\x3f\x53\xbc\x30\x12\x37\x1f\x08\x56\x31\xf6\x5f\xe8\x8d\xc8\xf8\xa1\xde\x74\x1e\xe5\x78\x96\x87\xa2\x3f\x2f\xf3\x6c\x54\xfa\xe8\x23\x08\x6b\x3c\x39\xae\x0c\x79\xe0\x27\x98\xbd\x57\xa6\x86\x77\x6f\xee\x17\x7f\xbe\xb9\x83\xc5\xfd\xed\xdd\x5f\xef\x66\x11\x22\x34\x94\x1a\x74\x58\x59\x87\x33\x50\xf4\x5d\xb8\xab\x84\x6d\x5b\x34\x12\x65\x20\x4c\x9a\xce\x94\x92\x85\x1a\x09\x5a\xeb\x86\xd9\xd6\xb8\x51\x4b\xa5\xc3\x30\x9f\xd5\x0f\xa2\x09\x07\xc0\x9f\xd8\x92\x7a\xfd\x91\x2b\x31\x7c\x30\xe5\xa5\xda\x50\xef\xf0\x68\x49\x28\x4f\xd5\xe6\xe2\x11\xb7\xe0\xd0\xf0\x36\x08\xfa\x8c\x39\xb0\x6e\xd0\x40\xdf\xd5\x8e\x4b\x65\xea\x08\x1a\xfc\xa8\x9c\x6d\x61\x75\xc9\x9e\xb1\x4b\x98\x28\xef\x7b\xbc\xf8\xfa\xea\xc7\x1f\xa6\x0c\x6e\x4f\xfa\x4b\xae\x1f\xa7\x68\xac\xe2\xac\xd8\x21\x18\x6e\x9b\xb2\x84\x87\x24\x53\xa5\x2a\x5f\xbc\x5a\xc4\x91\x15\x0e\x39\x29\x53\xcf\xc6\xa2\x4c\x1d\x3b\x1d\x46\xa0\x8b\xff\x8c\x88\x39\x6d\x3b\x1c\x51\x3c\xb9\x5e\x10\xec\xf2\x4c\xba\x15\x8c\x7f\xc3\x55\xc7\x6e\x5d\xb8\xb5\xf2\xec\x70\x7b\x2d\x6e\x61\x69\xad\xce\xf7\xb1\x92\x7b\x5c\x0f\x30\x91\x1d\x3d\x70\x30\xb8\x3e\x18\xa1\x15\x1a\x62\x79\xd5\x1b\x71\xcc\x9d\x04\xa2\x73\x82\x29\x3c\x1d\x70\x76\xe0\x90\x7a\x67\xe0\x49\x0a\xec\xa4\x5b\xcd\x41\xba\xd5\x1e\x12\xe5\x4d\x24\x3a\xf2\x69\x3d\xb2\x39\x4c\x8f\x8e\x1f\x08\x27\x7e\x44\x9d\x0e\xbb\x26\x82\x36\x30\xbc\x09\xec\x26\xfd\xce\x82\xa3\x1e\x18\x63\x43\x77\x7e\x4f\x2f\xce\x1f\xd1\xe7\x29\xa0\x73\xd6\x85\xf6\x0c\x2f\xd1\x2c\x44\x60\x7e\xb0\xe7\x1e\xd7\xc3\x8e\x89\x67\xd2\xad\x12\x1e\x63\x6c\x9a\x67\xaa\x8a\xc9\x5f\x5d\x83\x51\x3a\x60\x64\x83\xb8\xaa\x25\x76\x17\x80\xab\x49\x11\x5e\x96\x01\x7b\x0e\xdf\xae\x8a\x48\x30\xcd\xb3\x7d\x3e\x66\x0f\xab\xec\x28\x62\x06\xaf\xe3\x35\x1c\x69\x52\x5f\xde\x3a\x45\xf8\xda\xc2\x3a\xfc\xfa\x4f\x1c\x87\x30\x67\x6b\x50\xc6\x13\x72\x19\x5e\x03\xd7\x1b\x13\xe6\x82\x1a\x6c\x81\xd7\x3c\x2c\xa5\xab\x88\x13\x5f\xf2\x70\xe0\xcb\x32\x40\x8f\x3a\xe6\xd7\xa3\xa3\x0f\xc3\x68\x26\xce\xc9\xd8\xd2\x5f\xb8\x78\xac\x5d\xf8\x62\x98\x4c\x67\x60\x3d\x7b\x20\x69\x7b\x9a\xfe\x7c\xde\x86\xb2\xcc\x32\x6d\x6b\xf6\x92\x13\xd7\x93\xa8\x36\xb0\xec\x03\xdd\x47\xce\x1d\x38\x3e\x65\xdd\x1a\x94\x4d\x55\xb8\x7f\xec\x63\x98\xbe\xf9\x35\x3c\xf1\x27\x1a\xd2\x14\x06\x83\x12\xd8\x1c\xd6\xb3\x3c\xcb\x52\x78\x0e\xc9\xd8\x68\xc9\x97\xa7\xe0\x7f\x9a\x81\xe3\x07\xd0\xdf\x01\x00\x00\xff\xff\x77\x0b\x04\xcc\x2c\x0a\x00\x00") +var _templateMigrateMigrateTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xc4\x56\x5f\x6f\xdb\xb6\x17\x7d\x96\x3e\xc5\xfd\xe9\xb7\x75\x76\xe1\x50\x69\x86\x01\x9b\xd7\x3c\x74\x71\x3a\x18\xdb\xb2\x0e\x69\xd1\x3d\x96\x16\xaf\x24\x22\x14\xa9\x92\x57\x96\x0d\xc3\xdf\x7d\x20\x29\xf9\x4f\x93\xa2\x7b\xd8\xb0\xbc\x08\xb9\xbc\x3c\xe7\xde\x73\x2e\x49\xef\x76\xf9\xf3\xf4\xc6\xb4\x5b\x2b\xab\x9a\xe0\xea\xf2\xc5\x0f\x17\xad\x45\x87\x9a\xe0\x35\x2f\x70\x65\xcc\x03\x2c\x75\xc1\xe0\x95\x52\x10\x92\x1c\xf8\x75\xbb\x46\xc1\xd2\xb7\xb5\x74\xe0\x4c\x67\x0b\x84\xc2\x08\x04\xe9\x40\xc9\x02\xb5\x43\x01\x9d\x16\x68\x81\x6a\x84\x57\x2d\x2f\x6a\x84\x2b\x76\x39\xae\x42\x69\x3a\x2d\x52\xa9\xc3\xfa\xaf\xcb\x9b\xdb\xbb\xfb\x5b\x28\xa5\x42\x18\x62\xd6\x18\x02\x21\x2d\x16\x64\xec\x16\x4c\x09\x74\x42\x46\x16\x91\xa5\xcf\xf3\xfd\x3e\x4d\x77\x3b\x10\x58\x4a\x8d\x90\x35\xb2\xb2\x9c\x30\x83\x18\xbf\x80\x5e\x52\x0d\xb8\x21\xd4\x02\xbe\x82\xec\x0d\x2f\x1e\x78\x85\xd9\x49\xe6\xc5\x7e\x9f\x26\xbb\x1d\x10\x36\xad\xe2\x84\x90\xd5\xc8\x05\xda\x0c\x98\x47\xd9\xed\xc0\xef\xf5\x78\xb2\x69\x8d\x25\x98\xa4\x49\x56\x18\x4d\xb8\xa1\x2c\x4d\xb2\xb2\xa1\x2c\x4d\x93\xac\x92\x54\x77\x2b\x56\x98\x26\x2f\x07\xe1\x72\xd4\x94\x0b\xc9\x15\x16\x21\xf5\x0b\x29\xb9\xfb\xa8\x72\x57\xd4\xd8\xf0\x2c\x9d\xa6\xe9\x9a\x5b\x4f\x96\xe7\xf0\x5e\x52\xfd\xb3\x32\x2b\xae\xde\x69\xf9\xb1\xc3\xe5\x02\x1c\x92\x0b\x3a\x75\x5a\xae\xd1\x3a\xae\x40\x0a\x07\xa6\x25\x69\xb4\x03\x32\x61\x31\x76\x29\x8d\x66\x01\x67\x39\x88\x18\xb3\xbc\x59\xa8\xf9\x4a\xa1\x98\x81\x37\xfc\x90\x0d\xbd\x54\x0a\xb8\x52\xa6\xf0\x8a\x70\x78\xf1\xf2\xe5\xb7\x57\x60\xb9\xae\x30\x00\x95\x26\x1a\x1b\x28\x4b\x40\x5e\xd4\x1e\x41\xd2\x16\x26\xe4\x11\xa7\x91\xf0\xce\x10\x02\xd5\x9c\xce\x78\x0b\xae\xb5\x21\x58\x21\xf0\xb6\x55\x12\x05\x18\x0d\x61\x9b\x8b\xc9\x5c\x59\xe4\x62\x0b\xb8\x91\x8e\x58\x9a\x3c\xd1\xff\x35\x44\xa5\xd8\xe3\xb5\x83\x64\x0b\x6b\xda\x1b\xa3\xba\x46\x1f\xe5\x12\xd6\xb4\x50\xc4\xe0\x50\xce\x3f\xa1\x55\x80\x35\x4a\x0c\xd0\x2e\x40\x84\x5e\x7a\xb4\x08\x9d\x3f\x0f\x5e\xb4\x95\xa1\x1a\x4a\x89\x4a\x38\xe0\x5a\x00\x8a\x0a\x1d\x83\x70\x8e\x04\x96\xbc\x53\x14\xcc\x2b\xb9\x72\x38\x74\x7e\xd2\xc6\x59\xd7\xc7\xf8\x59\xc7\x4b\x2d\x70\xf3\x49\xc3\x32\xc4\xfe\x8d\x7e\x03\x32\x7e\xda\x6f\x3c\x8f\x62\x3c\xcb\x43\xd1\x9f\x6f\xf3\x6c\x54\xba\xe0\x23\x14\x46\x3b\xb2\x5c\x6a\x72\xc0\x4f\x30\x3b\x27\x75\x05\x1f\xde\xdd\x2d\xff\x78\x77\x0b\xcb\xbb\xc5\xed\x9f\x1f\x66\x01\xc2\x0b\x4a\x35\x5a\x2c\x8d\xc5\x19\x48\xfa\xc6\xdf\x55\x85\x69\x1a\xd4\x02\x85\x27\x8c\x3d\x9d\x75\x4a\x06\x2a\x24\x68\x8c\x1d\x66\x5b\xe1\x46\xae\xa4\xf2\xc3\x7c\x56\x3f\x14\xb5\x3f\x00\xee\xc4\x96\xa8\xf5\x23\x57\x42\xf8\x60\xca\x6b\xb9\xa1\xce\xe2\xd1\x12\x5f\x9e\xac\xf4\xc5\x03\x6e\xc1\xa2\xe6\x8d\x6f\xe8\x33\xe6\x40\x5f\xa3\x86\xae\xad\x2c\x17\x52\x57\x01\xd4\xfb\x51\x5a\xd3\xc0\xfa\x92\xbd\x60\x97\x30\x91\xce\x75\x78\xf1\xff\xab\xef\xbf\x9b\x32\x58\x9c\xe8\x4b\xb6\x1b\xa7\x68\xac\xe2\xac\xd8\x21\x78\x2c\x35\x54\x56\xff\x82\x5b\xb7\x90\x2e\x48\x25\xe2\xd7\x41\x61\x91\x93\xaf\x34\x96\x5f\x87\xf2\xa5\x06\x21\x14\x83\xa5\x06\x67\x1a\x84\x82\x3b\x84\x1e\xbd\x61\x01\xd4\x9f\x73\x7f\x8f\xf4\x51\xfe\xce\xe1\xe9\xf6\xf3\x62\xc3\x30\x0c\xc5\x3e\xae\xe3\xbc\xee\x47\xeb\xfe\xc2\xcc\x73\xb8\x8f\x4e\xc9\x28\xf4\xab\x37\xcb\x70\xea\xc6\xd2\x67\xa3\xae\xba\x0a\xc3\xe2\xa7\xb8\x0d\xff\x8c\xe0\x29\x6d\x5b\x1c\x51\x1c\xd9\xae\x20\xd8\xa5\x89\xb0\x6b\x18\xff\x86\xdb\x9a\x2d\xac\xbf\x78\xd3\xe4\x70\x01\x2f\x17\xb0\x32\x46\xa5\xfb\x50\xc9\x1d\xf6\x03\x4c\x60\x47\x07\x1c\x34\xf6\x87\x59\x52\x12\x35\xb1\xb4\xec\x74\x71\xcc\x9d\x78\xa2\x73\x82\x29\x3c\x1f\x70\x76\x60\x91\x3a\xab\xe1\x59\x0c\xec\x84\x5d\xcf\x41\xd8\xf5\x1e\x22\xe5\x4d\x20\x3a\xf2\x29\x35\xb2\x59\x8c\xef\xa6\x1b\x08\x27\x6e\x44\x9d\x0e\xbb\x26\x05\x6d\x60\x78\xd6\xd8\x4d\xfc\xce\xfc\x50\x3a\x60\x8c\x0d\xea\xfc\x16\x1f\xcd\xdf\xc3\xa8\x4e\x01\xad\x35\xd6\xcb\x33\x3c\xa6\x33\x1f\x81\xf9\xc1\xa9\x3b\xec\x87\x1d\x13\xc7\x84\x5d\x47\x3c\xc6\xd8\x34\x4d\x64\x19\x92\xff\x77\x0d\x5a\x2a\x8f\x91\x0c\xcd\x95\x0d\xb1\x5b\x0f\x5c\x4e\x32\xff\x38\x0e\xd8\x73\xf8\x7a\x9d\x05\x82\x69\x9a\xec\xd3\x31\x7b\x58\x65\xc7\x26\x66\xf0\x36\xcc\x6b\xa0\x89\xba\xbc\xb7\x92\xf0\xad\x81\xde\x7f\xdd\x13\x27\xda\x4f\x5f\x0f\x52\x3b\x42\x2e\xfc\x83\x66\x3b\xad\xfd\x5c\x50\x8d\x0d\xf0\x8a\xfb\xa5\x78\x9b\x72\xe2\x2b\xee\xef\xac\x3c\xf7\xd0\x63\x1f\xf3\xeb\xd1\xd1\xfb\x61\x4a\x23\xe7\x64\x94\xf4\x27\x5e\x3c\x54\xd6\xff\xe8\x99\x4c\x67\x60\x1c\xbb\x27\x61\x3a\x9a\xfe\x78\x2e\x43\x9e\x27\x89\x32\x15\x7b\xcd\x89\xab\x49\xe8\xd6\xb3\xec\x3d\xdd\x23\xe7\x0e\x1c\x4f\x59\xd7\x83\x34\xb1\x0a\xfb\xb7\x7d\xf4\xd3\x37\xbf\x86\x67\xee\xa4\x87\x38\x85\xde\xa0\x08\x36\x87\x7e\x96\x26\x49\x0c\xcf\x21\x1a\x1b\x2c\xf9\xf2\x14\xfc\x47\x33\x70\xfc\x0d\xf7\x57\x00\x00\x00\xff\xff\x5d\x33\x79\xab\xef\x0a\x00\x00") func templateMigrateMigrateTmplBytes() ([]byte, error) { return bindataRead( @@ -1001,7 +1001,7 @@ func templateMigrateMigrateTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "template/migrate/migrate.tmpl", size: 2604, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "template/migrate/migrate.tmpl", size: 2799, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/entc/gen/template/migrate/migrate.tmpl b/entc/gen/template/migrate/migrate.tmpl index f7cb5a6b4..8f89e6662 100644 --- a/entc/gen/template/migrate/migrate.tmpl +++ b/entc/gen/template/migrate/migrate.tmpl @@ -38,6 +38,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/config/ent/migrate/migrate.go b/entc/integration/config/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/config/ent/migrate/migrate.go +++ b/entc/integration/config/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/customid/ent/migrate/migrate.go b/entc/integration/customid/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/customid/ent/migrate/migrate.go +++ b/entc/integration/customid/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/ent/migrate/migrate.go b/entc/integration/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/ent/migrate/migrate.go +++ b/entc/integration/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/hooks/ent/migrate/migrate.go b/entc/integration/hooks/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/hooks/ent/migrate/migrate.go +++ b/entc/integration/hooks/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/idtype/ent/migrate/migrate.go b/entc/integration/idtype/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/idtype/ent/migrate/migrate.go +++ b/entc/integration/idtype/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/json/ent/migrate/migrate.go b/entc/integration/json/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/json/ent/migrate/migrate.go +++ b/entc/integration/json/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/migrate/entv1/migrate/migrate.go b/entc/integration/migrate/entv1/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/migrate/entv1/migrate/migrate.go +++ b/entc/integration/migrate/entv1/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/migrate/entv2/migrate/migrate.go b/entc/integration/migrate/entv2/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/migrate/entv2/migrate/migrate.go +++ b/entc/integration/migrate/entv2/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/privacy/ent/migrate/migrate.go b/entc/integration/privacy/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/privacy/ent/migrate/migrate.go +++ b/entc/integration/privacy/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/entc/integration/template/ent/migrate/migrate.go b/entc/integration/template/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/entc/integration/template/ent/migrate/migrate.go +++ b/entc/integration/template/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/edgeindex/ent/migrate/migrate.go b/examples/edgeindex/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/edgeindex/ent/migrate/migrate.go +++ b/examples/edgeindex/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/entcpkg/ent/migrate/migrate.go b/examples/entcpkg/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/entcpkg/ent/migrate/migrate.go +++ b/examples/entcpkg/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/m2m2types/ent/migrate/migrate.go b/examples/m2m2types/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/m2m2types/ent/migrate/migrate.go +++ b/examples/m2m2types/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/m2mbidi/ent/migrate/migrate.go b/examples/m2mbidi/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/m2mbidi/ent/migrate/migrate.go +++ b/examples/m2mbidi/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/m2mrecur/ent/migrate/migrate.go b/examples/m2mrecur/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/m2mrecur/ent/migrate/migrate.go +++ b/examples/m2mrecur/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/o2m2types/ent/migrate/migrate.go b/examples/o2m2types/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/o2m2types/ent/migrate/migrate.go +++ b/examples/o2m2types/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/o2mrecur/ent/migrate/migrate.go b/examples/o2mrecur/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/o2mrecur/ent/migrate/migrate.go +++ b/examples/o2mrecur/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/o2o2types/ent/migrate/migrate.go b/examples/o2o2types/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/o2o2types/ent/migrate/migrate.go +++ b/examples/o2o2types/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/o2obidi/ent/migrate/migrate.go b/examples/o2obidi/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/o2obidi/ent/migrate/migrate.go +++ b/examples/o2obidi/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/o2orecur/ent/migrate/migrate.go b/examples/o2orecur/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/o2orecur/ent/migrate/migrate.go +++ b/examples/o2orecur/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/start/ent/migrate/migrate.go b/examples/start/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/start/ent/migrate/migrate.go +++ b/examples/start/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema. diff --git a/examples/traversal/ent/migrate/migrate.go b/examples/traversal/ent/migrate/migrate.go index a8d4b46e7..8f3fdd064 100644 --- a/examples/traversal/ent/migrate/migrate.go +++ b/examples/traversal/ent/migrate/migrate.go @@ -35,6 +35,9 @@ var ( // WithFixture sets the foreign-key renaming option to the migration when upgrading // ent from v0.1.0 (issue-#285). Defaults to true. WithFixture = schema.WithFixture + // WithForeighKeysDisable disables creating foreigh-key in ddl. In some case we are + // not allowed to use foreigh-key. Defaults to false + WithForeighKeysDisable = schema.WithForeighKeysDisable ) // Schema is the API for creating, migrating and dropping a schema.