diff --git a/dirs/coder/migrations/20260715153434.sql b/dirs/coder/migrations/20260715153434.sql new file mode 100644 index 0000000..fd124d0 --- /dev/null +++ b/dirs/coder/migrations/20260715153434.sql @@ -0,0 +1,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; diff --git a/dirs/coder/migrations/atlas.sum b/dirs/coder/migrations/atlas.sum index c0c79ae..ccbe080 100644 --- a/dirs/coder/migrations/atlas.sum +++ b/dirs/coder/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:Xow5vrkYyq9fDu4ypd4GuVOziNIHLz6eNzvJ5uIsa1Q= +h1:O84kvpde0vh4XjFabK26A6TJw5dJycsEZAQ0et9+u/g= 20251231090037_initial.sql h1:U5btCTuW+yflxpBpF1HoT9wp65mIiVYACHJeMQDOz+w= 20251231091921.sql h1:11zz1Nrb2G45QCbRrGub10D2vZuzdJbY6PkYXzrvsQg= 20251231150752.sql h1:kIQVr/QD6yFkwJonS3JQa0/UXWwbRLVLgbnqTPrbaUk= @@ -61,3 +61,4 @@ h1:Xow5vrkYyq9fDu4ypd4GuVOziNIHLz6eNzvJ5uIsa1Q= 20260708154845.sql h1:TkTk2T4D79UgFi1HvWxj1wntsi578gVWZeClthsTZWI= 20260710155111.sql h1:KurSVe2Z9NT3nA1BoSzJnEYrkY169nNeffVMebuxcK8= 20260713155709.sql h1:Tec2cRjDhADirEz8xBWo0A0tLyEVjWHMRE1EhxCqD+s= +20260715153434.sql h1:OLvFfcmxKd4MaujwQK+8Ih2SbUQsx7pDv3aum5krbrA= diff --git a/dirs/coder/schema.sql b/dirs/coder/schema.sql index d661620..34c8b10 100644 --- a/dirs/coder/schema.sql +++ b/dirs/coder/schema.sql @@ -99,7 +99,7 @@ CREATE TABLE "public"."api_keys" ( "id" text NOT NULL, "hashed_secret" bytea NOT NULL, "user_id" uuid NOT NULL, - "last_used" timestamptz NOT NULL, + "last_used_at" timestamptz NOT NULL, "expires_at" timestamptz NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, @@ -112,9 +112,9 @@ CREATE TABLE "public"."api_keys" ( CONSTRAINT "api_keys_user_id_uuid_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON UPDATE NO ACTION ON DELETE CASCADE, CONSTRAINT "api_keys_lifetime_seconds_non_negative" CHECK (lifetime_seconds >= 0), CONSTRAINT "api_keys_expires_at_not_before_created_at" CHECK (expires_at >= created_at), - CONSTRAINT "api_keys_expires_at_not_before_last_used" CHECK (expires_at >= last_used), + CONSTRAINT "api_keys_expires_at_not_before_last_used" CHECK (expires_at >= last_used_at), CONSTRAINT "api_keys_token_name_no_surrounding_whitespace" CHECK (token_name = btrim(token_name)), - CONSTRAINT "api_keys_last_used_not_before_sentinel" CHECK (last_used >= TIMESTAMPTZ '0001-01-01 00:00:00+00'), + CONSTRAINT "api_keys_last_used_not_before_sentinel" CHECK (last_used_at >= TIMESTAMPTZ '0001-01-01 00:00:00+00'), CONSTRAINT "api_keys_ip_address_not_unspecified_v6" CHECK (ip_address <> '::'::inet), CONSTRAINT "api_keys_token_name_not_empty" CHECK (length(btrim(token_name)) > 0), CONSTRAINT "api_keys_hashed_secret_not_empty" CHECK (octet_length(hashed_secret) > 0),