only postgres14

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

atlas migrate hash --force

# 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 GENERATED BY DEFAULT AS IDENTITY, "age" bigint NOT NULL, "name" character varying NOT NULL, PRIMARY KEY \("id"\)\);'
stdout '-- migrating version 2'
stdout '-> CREATE UNIQUE INDEX "users_age_key" ON "users" \("age"\);'
stdout '-- migrating version 3'
stdout '-> CREATE TABLE "pets" \("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, PRIMARY KEY \("id"\)\);'
stdout '-- 3 migrations'
stdout '-- 3 sql statements'
cmpshow users users.sql
cmpshow pets pets.sql

atlas migrate apply --url URL --revisions-schema $db 1
stdout 'The migration directory is synced with the database, 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 'The migration directory is synced with the database, no migration files to execute'

-- migrations/1_first.sql --
CREATE TABLE "users" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "age" bigint NOT NULL, "name" character varying NOT NULL, PRIMARY KEY ("id"));

-- migrations/2_second.sql --
CREATE UNIQUE INDEX "users_age_key" ON "users" ("age");

-- migrations/3_third.sql --
CREATE TABLE "pets" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, PRIMARY KEY ("id"));

-- users.sql --
                        Table "script_cli_migrate_apply.users"
 Column |       Type        | Collation | Nullable |             Default
--------+-------------------+-----------+----------+----------------------------------
 id     | bigint            |           | not null | generated by default as identity
 age    | bigint            |           | not null |
 name   | character varying |           | not null |
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
    "users_age_key" UNIQUE, btree (age)

-- users_1.sql --
                        Table "script_cli_migrate_apply.users"
 Column |       Type        | Collation | Nullable |             Default
--------+-------------------+-----------+----------+----------------------------------
 id     | bigint            |           | not null | generated by default as identity
 age    | bigint            |           | not null |
 name   | character varying |           | not null |
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)

-- pets.sql --
                        Table "script_cli_migrate_apply.pets"
 Column |       Type        | Collation | Nullable |             Default
--------+-------------------+-----------+----------+----------------------------------
 id     | bigint            |           | not null | generated by default as identity
 name   | character varying |           | not null |
Indexes:
    "pets_pkey" PRIMARY KEY, btree (id)
