Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add methods for migrate #174

Merged
merged 23 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: tests
  • Loading branch information
devhaozi committed Jun 10, 2023
commit 7bd3d1a480d707deedc2e621b9b73c2cc684b0d8
12 changes: 12 additions & 0 deletions database/console/migrate_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func createMysqlMigrations() {
KEY idx_agents_updated_at (updated_at)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
INSERT INTO agents (name, created_at, updated_at) VALUES ('goravel', '2023-03-11 16:07:41', '2023-03-11 16:07:45');
`)
_ = file.Create("database/migrations/20230311160527_create_agents_table.down.sql",
`DROP TABLE agents;
`)
}

Expand All @@ -128,6 +131,9 @@ func createPostgresqlMigrations() {
updated_at timestamp NOT NULL
);
INSERT INTO agents (name, created_at, updated_at) VALUES ('goravel', '2023-03-11 16:07:41', '2023-03-11 16:07:45');
`)
_ = file.Create("database/migrations/20230311160527_create_agents_table.down.sql",
`DROP TABLE agents;
`)
}

Expand All @@ -141,6 +147,9 @@ func createSqlserverMigrations() {
PRIMARY KEY (id)
);
INSERT INTO agents (name, created_at, updated_at) VALUES ('goravel', '2023-03-11 16:07:41', '2023-03-11 16:07:45');
`)
_ = file.Create("database/migrations/20230311160527_create_agents_table.down.sql",
`DROP TABLE agents;
`)
}

Expand All @@ -153,6 +162,9 @@ func createSqliteMigrations() {
updated_at datetime NOT NULL
);
INSERT INTO agents (name, created_at, updated_at) VALUES ('goravel', '2023-03-11 16:07:41', '2023-03-11 16:07:45');
`)
_ = file.Create("database/migrations/20230311160527_create_agents_table.down.sql",
`DROP TABLE agents;
`)
}

Expand Down
2 changes: 2 additions & 0 deletions database/console/migrate_rollback_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func TestMigrateRollbackCommand(t *testing.T) {
migrateCommand := NewMigrateCommand(mockConfig)
assert.Nil(t, migrateCommand.Handle(mockContext))

mockConfig.On("Get", "step").Return(1).Once()

migrateRollbackCommand := NewMigrateRollbackCommand(mockConfig)
assert.Nil(t, migrateRollbackCommand.Handle(mockContext))

devhaozi marked this conversation as resolved.
Show resolved Hide resolved
Expand Down