exec mkdir migrations

! atlas migrate diff --to file://1.hcl --dir file://migrations
stderr '"dev-url" not set'

! atlas migrate diff --dev-url postgres://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

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

table "users" {
  schema = schema.script_cli_migrate_diff
  column "id" {
    null = false
    type = bigint
  }
  primary_key  {
    columns = [column.id]
  }
}

-- 1.sql --
-- Create "users" table
CREATE TABLE "users" ("id" bigint NOT NULL, PRIMARY KEY ("id"));

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

table "users" {
  schema = schema.script_cli_migrate_diff
  column "id" {
    null = false
    type = bigint
  }
  column "create_time" {
    null    = false
    type    = timestamp(4)
    default = sql("CURRENT_TIMESTAMP(4)")
  }
  primary_key  {
    columns = [column.id]
  }
}

-- 2.sql --
-- Modify "users" table
ALTER TABLE "users" ADD COLUMN "create_time" timestamp(4) NOT NULL DEFAULT CURRENT_TIMESTAMP(4);