Skip to content

Commit e57c0fe

Browse files
committed
database migration
1 parent 762cdbe commit e57c0fe

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { type MigrationExecutor } from '../pg-migrator';
2+
3+
export default {
4+
name: '2025.10.17T00-00-00.personal-access-tokens.ts',
5+
run: ({ sql }) => sql`
6+
CREATE TABLE IF NOT EXISTS "personal_access_tokens" (
7+
"id" UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4()
8+
, "organization_id" UUID NOT NULL REFERENCES "organizations" ("id") ON DELETE CASCADE
9+
, "user_id" UUID NOT NULL REFERENCES "users" ("id") ON DELETE CASCADE
10+
, "created_at" timestamptz NOT NULL DEFAULT now()
11+
, "title" text NOT NULL
12+
, "description" text NOT NULL
13+
, "permissions" text[] NOT NULL
14+
, "assigned_resources" jsonb
15+
, "hash" text NOT NULL
16+
, "first_characters" text NOT NULL
17+
);
18+
19+
CREATE INDEX IF NOT EXISTS "personal_access_tokens_organization_id" ON "personal_access_tokens" (
20+
"organization_id"
21+
, "user_id"
22+
, "created_at" DESC
23+
, "id" DESC
24+
);
25+
`,
26+
} satisfies MigrationExecutor;

packages/migrations/src/run-pg-migrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,6 @@ export const runPGMigrations = async (args: { slonik: DatabasePool; runTo?: stri
167167
await import('./actions/2025.05.15T00-00-00.contracts-foreign-key-constraint-fix'),
168168
await import('./actions/2025.05.15T00-00-01.organization-member-pagination'),
169169
await import('./actions/2025.05.28T00-00-00.schema-log-by-ids'),
170+
await import('./actions/2025.10.17T00-00-00.personal-access-tokens'),
170171
],
171172
});

0 commit comments

Comments
 (0)