only mysql

! atlas migrate apply
stderr 'Error: checksum file not found'
stdout 'You have a checksum error in your migration directory.'
stdout 'atlas migrate hash'

atlas migrate hash

# Apply all of them
atlas migrate apply --url URL --revisions-schema $db
stdout 'Migrating to version 3 \(3 migrations in total\):'
stdout '-- migrating version 1'
stdout '-> CREATE TABLE `users` \(`id` bigint NOT NULL AUTO_INCREMENT, `age` bigint NOT NULL, `name` varchar\(255\) NOT NULL, PRIMARY KEY \(`id`\)\) CHARSET utf8mb4 COLLATE utf8mb4_bin;'
stdout '-- migrating version 2'
stdout '-> ALTER TABLE `users` ADD UNIQUE INDEX `age` \(`age`\);'
stdout '-- migrating version 3'
stdout '-> CREATE TABLE `pets` \(`id` bigint NOT NULL AUTO_INCREMENT, `name` varchar\(255\) NOT NULL, PRIMARY KEY \(`id`\)\) CHARSET utf8mb4 COLLATE utf8mb4_bin;'
stdout '-- 3 migrations'
stdout '-- 3 sql statements'
cmpshow users users.sql
cmpshow pets pets.sql

atlas migrate apply --url URL --revisions-schema $db
stdout 'No migration files to execute'

clearSchema

# Apply one by one
atlas migrate apply --url URL --revisions-schema $db 1
stdout 'Migrating to version 1 \(1 migrations in total\):'
cmpshow users users_1.sql

atlas migrate apply --url URL --revisions-schema $db 1
stdout 'Migrating to version 2 from 1 \(1 migrations in total\):'
cmpshow users users.sql

atlas migrate apply --url URL --revisions-schema $db 1
stdout 'Migrating to version 3 from 2 \(1 migrations in total\):'
cmpshow users users.sql
cmpshow pets pets.sql

atlas migrate apply --url URL --revisions-schema $db 1
stdout 'No migration files to execute'

clearSchema

atlas migrate apply --url URL --revisions-schema $db --log '{{ json . }}'
validJSON stdout
stdout '"Driver":"mysql"'
stdout '"Scheme":"mysql"'
stdout '"Dir":"migrations"'
stdout '"Target":"3"'
stdout '"Pending":\[{"Name":"1_first.sql","Version":"1","Description":"first"},{"Name":"2_second.sql","Version":"2","Description":"second"},{"Name":"3_third.sql","Version":"3","Description":"third"}\]'
stdout '"Applied":\["CREATE TABLE `users` \(`id` bigint NOT NULL AUTO_INCREMENT, `age` bigint NOT NULL, `name` varchar\(255\) NOT NULL, PRIMARY KEY \(`id`\)\) CHARSET utf8mb4 COLLATE utf8mb4_bin;"\]'
stdout '"Start":"\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.[0-9]'

-- migrations/1_first.sql --
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, `age` bigint NOT NULL, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_bin;

-- migrations/2_second.sql --
ALTER TABLE `users` ADD UNIQUE INDEX `age` (`age`);

-- migrations/3_third.sql --
CREATE TABLE `pets` (`id` bigint NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_bin;

-- users.sql --
CREATE TABLE `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `age` bigint(20) NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `age` (`age`)
)

-- mysql8/users.sql --
CREATE TABLE `users` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `age` bigint NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `age` (`age`)
)

-- users_1.sql --
CREATE TABLE `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `age` bigint(20) NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`id`)
)

-- mysql8/users_1.sql --
CREATE TABLE `users` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `age` bigint NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`id`)
)

-- pets.sql --
CREATE TABLE `pets` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`id`)
)

-- mysql8/pets.sql --
CREATE TABLE `pets` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`id`)
)
