1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
only maria107 maria102
exec mkdir migrations
! atlas migrate diff --to file://1.hcl --dir file://migrations
stderr '"dev-url" not set'
! atlas migrate diff --dev-url mysql://devdb --dir file://migrations
stderr '"to" not set'
atlas migrate diff --dev-url URL --to file://./1.hcl first
cmpmig 0 1.sql
atlas migrate diff --dev-url URL --to file://./2.hcl second
cmpmig 1 2.sql
# Clean migration directory and run diff with a custom qualifier.
exec rm -rf migrations
atlas migrate diff --dev-url URL --to file://./1.hcl --qualifier test first
cmpmig 0 1-qualifier.sql
-- 1.hcl --
schema "script_cli_migrate_diff" {}
table "users" {
schema = schema.script_cli_migrate_diff
column "id" {
null = false
type = bigint
auto_increment = true
}
primary_key {
columns = [column.id]
}
charset = "utf8mb4"
collate = "utf8mb4_general_ci"
}
-- 1.sql --
-- create "users" table
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
-- 1-qualifier.sql --
-- create "users" table
CREATE TABLE `test`.`users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
-- 2.hcl --
schema "script_cli_migrate_diff" {}
table "users" {
schema = schema.script_cli_migrate_diff
column "id" {
null = false
type = bigint
auto_increment = true
}
column "create_time" {
null = false
type = timestamp(6)
default = sql("CURRENT_TIMESTAMP(6)")
}
primary_key {
columns = [column.id]
}
charset = "utf8mb4"
collate = "utf8mb4_general_ci"
}
-- 2.sql --
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `create_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6);
-- maria102/2.sql --
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `create_time` timestamp(6) NOT NULL DEFAULT (current_timestamp(6));
-- maria107/2.sql --
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `create_time` timestamp(6) NOT NULL DEFAULT (current_timestamp(6));
|