mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: disable fixture in default migration (#753)
This commit is contained in:
@@ -52,7 +52,7 @@ func WithDropIndex(b bool) MigrateOption {
|
||||
}
|
||||
|
||||
// WithFixture sets the foreign-key renaming option to the migration when upgrading
|
||||
// ent from v0.1.0 (issue-#285). Defaults to true.
|
||||
// ent from v0.1.0 (issue-#285). Defaults to false.
|
||||
func WithFixture(b bool) MigrateOption {
|
||||
return func(m *Migrate) {
|
||||
m.withFixture = b
|
||||
@@ -71,7 +71,7 @@ type Migrate struct {
|
||||
|
||||
// NewMigrate create a migration structure for the given SQL driver.
|
||||
func NewMigrate(d dialect.Driver, opts ...MigrateOption) (*Migrate, error) {
|
||||
m := &Migrate{withFixture: true}
|
||||
m := &Migrate{}
|
||||
switch d.Dialect() {
|
||||
case dialect.MySQL:
|
||||
m.sqlDialect = &MySQL{Driver: d}
|
||||
|
||||
@@ -699,11 +699,6 @@ func TestMySQL_Create(t *testing.T) {
|
||||
AddRow("PRIMARY", "id", "0", "1").
|
||||
AddRow("old_index", "old", "0", "1").
|
||||
AddRow("parent_id", "parent_id", "0", "1"))
|
||||
mock.fkExists("parent_id", true)
|
||||
mock.ExpectQuery(escape("SELECT `column_name` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS t1 JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS t2 ON `t1`.`constraint_name` = `t2`.`constraint_name` WHERE `t2`.`constraint_type` = 'FOREIGN KEY' AND `t2`.`table_schema` = (SELECT DATABASE()) AND `t1`.`table_schema` = (SELECT DATABASE()) AND `t2`.`constraint_name` = ?")).
|
||||
WithArgs("parent_id").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"COLUMN_NAME"}).
|
||||
AddRow("parent_id"))
|
||||
// drop the unique index.
|
||||
mock.ExpectExec(escape("DROP INDEX `old_index` ON `users`")).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
@@ -833,7 +828,6 @@ func TestMySQL_Create(t *testing.T) {
|
||||
WithArgs("users").
|
||||
WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "non_unique", "seq_in_index"}).
|
||||
AddRow("PRIMARY", "id", "0", "1"))
|
||||
mock.fkExists("user_spouse_____________________390ed76f91d3c57cd3516e7690f621dc", false)
|
||||
mock.ExpectExec(escape("ALTER TABLE `users` ADD COLUMN `spouse_id` bigint NULL")).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
mock.fkExists("user_spouse_____________________390ed76f91d3c57cd3516e7690f621dc", false)
|
||||
|
||||
@@ -565,7 +565,6 @@ func TestPostgres_Create(t *testing.T) {
|
||||
mock.ExpectQuery(escape(fmt.Sprintf(indexesQuery, "users"))).
|
||||
WillReturnRows(sqlmock.NewRows([]string{"index_name", "column_name", "primary", "unique", "seq_in_index"}).
|
||||
AddRow("users_pkey", "id", "t", "t", 0))
|
||||
mock.fkExists("user_spouse____________________390ed76f91d3c57cd3516e7690f621dc", false)
|
||||
mock.ExpectExec(escape(`ALTER TABLE "users" ADD COLUMN "spouse_id" bigint NULL`)).
|
||||
WillReturnResult(sqlmock.NewResult(0, 1))
|
||||
mock.fkExists("user_spouse____________________390ed76f91d3c57cd3516e7690f621dc", false)
|
||||
|
||||
Reference in New Issue
Block a user