Skip to content

[Coder] Schema update - #489

Open
ariga-bot wants to merge 1 commit into
masterfrom
f/coder-171469
Open

[Coder] Schema update#489
ariga-bot wants to merge 1 commit into
masterfrom
f/coder-171469

Conversation

@ariga-bot

Copy link
Copy Markdown
Collaborator

Backward-incompatible change: renamed column last_used to last_used_at in public.api_keys. Applications referencing api_keys.last_used will break until updated.

…t_used_at in public.api_keys. Applications referencing api_keys.last_used will break until updated.
@github-actions

Copy link
Copy Markdown
Contributor

atlas migrate lint on dirs/coder/migrations

Status Step Result
1 new migration file detected 20260715153434.sql
ERD and visual diff generated View Visualization
Analyze 20260715153434.sql
2 reports were found in analysis
Destructive changes detected
Dropping non-virtual column "last_used" (DS103)
Data dependent changes detected
Adding a non-nullable "timestamptz" column "last_used_at" will fail in case table "api_keys" is not empty (MF103)
Read the full linting report on Atlas Cloud

Comment on lines +1 to +2
-- Modify "api_keys" table
ALTER TABLE "api_keys" DROP CONSTRAINT "api_keys_expires_at_not_before_last_used", ADD CONSTRAINT "api_keys_expires_at_not_before_last_used" CHECK (expires_at >= last_used_at), DROP CONSTRAINT "api_keys_last_used_not_before_sentinel", ADD CONSTRAINT "api_keys_last_used_not_before_sentinel" CHECK (last_used_at >= '0001-01-01 00:00:00+00'::timestamp with time zone), DROP COLUMN "last_used", ADD COLUMN "last_used_at" timestamptz NOT NULL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

destructive changes detected
Dropping non-virtual column "last_used" DS103

Add a pre-migration check to ensure column "last_used" is NULL before dropping it

Suggested change
-- Modify "api_keys" table
ALTER TABLE "api_keys" DROP CONSTRAINT "api_keys_expires_at_not_before_last_used", ADD CONSTRAINT "api_keys_expires_at_not_before_last_used" CHECK (expires_at >= last_used_at), DROP CONSTRAINT "api_keys_last_used_not_before_sentinel", ADD CONSTRAINT "api_keys_last_used_not_before_sentinel" CHECK (last_used_at >= '0001-01-01 00:00:00+00'::timestamp with time zone), DROP COLUMN "last_used", ADD COLUMN "last_used_at" timestamptz NOT NULL;
-- atlas:txtar
-- checks/destructive.sql --
-- atlas:assert DS103
SELECT NOT EXISTS (SELECT 1 FROM "public"."api_keys" WHERE "last_used" IS NOT NULL) AS "is_empty";
-- migration.sql --
-- Modify "api_keys" table
ALTER TABLE "api_keys" DROP CONSTRAINT "api_keys_expires_at_not_before_last_used", ADD CONSTRAINT "api_keys_expires_at_not_before_last_used" CHECK (expires_at >= last_used_at), DROP CONSTRAINT "api_keys_last_used_not_before_sentinel", ADD CONSTRAINT "api_keys_last_used_not_before_sentinel" CHECK (last_used_at >= '0001-01-01 00:00:00+00'::timestamp with time zone), DROP COLUMN "last_used", ADD COLUMN "last_used_at" timestamptz NOT NULL;

Ensure to run atlas migrate hash --dir "file://dirs/coder/migrations" after applying the suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant