only maria103

mkdir migrations

# old behavior still works
atlas migrate diff --dev-url URL --to file://1.hcl --dir-format golang-migrate first
cmpmig 0 golang-migrate/1.down.sql
cmpmig 1 golang-migrate/1.up.sql

atlas migrate diff --dev-url URL --to file://2.hcl --dir-format golang-migrate second
cmpmig 2 golang-migrate/2.down.sql
cmpmig 3 golang-migrate/2.up.sql

rm migrations
mkdir migrations

atlas migrate diff --dev-url URL --to file://1.hcl --dir file://migrations?format=golang-migrate first
cmpmig 0 golang-migrate/1.down.sql
cmpmig 1 golang-migrate/1.up.sql

atlas migrate diff --dev-url URL --to file://2.hcl --dir file://migrations?format=golang-migrate second
cmpmig 2 golang-migrate/2.down.sql
cmpmig 3 golang-migrate/2.up.sql

rm migrations
mkdir migrations

atlas migrate diff --dev-url URL --to file://1.hcl --dir file://migrations?format=goose first
cmpmig 0 goose/1.sql

atlas migrate diff --dev-url URL --to file://2.hcl --dir file://migrations?format=goose second
cmpmig 1 goose/2.sql

rm migrations
mkdir migrations

atlas migrate diff --dev-url URL --to file://1.hcl --dir file://migrations?format=dbmate first
cmpmig 0 dbmate/1.sql

atlas migrate diff --dev-url URL --to file://2.hcl --dir file://migrations?format=dbmate second
cmpmig 1 dbmate/2.sql

rm migrations
mkdir migrations

atlas migrate diff --dev-url URL --to file://1.hcl --dir file://migrations?format=flyway first
cmpmig 0 flyway/U1.sql
cmpmig 1 flyway/V1.sql

atlas migrate diff --dev-url URL --to file://2.hcl --dir file://migrations?format=flyway second
cmpmig 1 flyway/U2.sql
cmpmig 3 flyway/V2.sql

rm migrations
mkdir migrations

atlas migrate diff --dev-url URL --to file://1.hcl --dir file://migrations?format=liquibase first
cmpmig 0 liquibase/1.sql

atlas migrate diff --dev-url URL --to file://2.hcl --dir file://migrations?format=liquibase second
cmpmig 1 liquibase/2.sql

-- golang-migrate/1.up.sql --
-- create "users" table
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

-- golang-migrate/1.down.sql --
-- reverse: create "users" table
DROP TABLE `users`;

-- golang-migrate/2.up.sql --
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `email` varchar(100) NULL;

-- golang-migrate/2.down.sql --
-- reverse: modify "users" table
ALTER TABLE `users` DROP COLUMN `email`;

-- goose/1.sql --
-- +goose Up
-- create "users" table
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

-- +goose Down
-- reverse: create "users" table
DROP TABLE `users`;

-- goose/2.sql --
-- +goose Up
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `email` varchar(100) NULL;

-- +goose Down
-- reverse: modify "users" table
ALTER TABLE `users` DROP COLUMN `email`;

-- dbmate/1.sql --
-- migrate:up
-- create "users" table
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

-- migrate:down
-- reverse: create "users" table
DROP TABLE `users`;

-- dbmate/2.sql --
-- migrate:up
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `email` varchar(100) NULL;

-- migrate:down
-- reverse: modify "users" table
ALTER TABLE `users` DROP COLUMN `email`;

-- flyway/V1.sql --
-- create "users" table
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;

-- flyway/U1.sql --
-- reverse: create "users" table
DROP TABLE `users`;

-- flyway/V2.sql --
-- modify "users" table
ALTER TABLE `users` ADD COLUMN `email` varchar(100) NULL;

-- flyway/U2.sql --
-- reverse: modify "users" table
ALTER TABLE `users` DROP COLUMN `email`;

-- liquibase/1.sql --
--liquibase formatted sql
--changeset atlas:0-0
--comment: create "users" table
CREATE TABLE `users` (`id` bigint NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`)) CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
--rollback: DROP TABLE `users`;

-- liquibase/2.sql --
--liquibase formatted sql
--changeset atlas:0-0
--comment: modify "users" table
ALTER TABLE `users` ADD COLUMN `email` varchar(100) NULL;
--rollback: ALTER TABLE `users` DROP COLUMN `email`;

-- 1.hcl --
schema "script_cli_migrate_diff_format" {}

table "users" {
  schema = schema.script_cli_migrate_diff_format
  column "id" {
    null = false
    type = bigint
    auto_increment = true
  }
  primary_key  {
    columns = [column.id]
  }
  charset = "utf8mb4"
  collate = "utf8mb4_general_ci"
}

-- 2.hcl --
schema "script_cli_migrate_diff_format" {}

table "users" {
  schema = schema.script_cli_migrate_diff_format
  column "id" {
    null = false
    type = bigint
    auto_increment = true
  }
  column "email" {
    null = true
    type = varchar(100)
  }
  primary_key  {
    columns = [column.id]
  }
  charset = "utf8mb4"
  collate = "utf8mb4_general_ci"
}