diff options
author | hailey <hailey@blueskyweb.xyz> | 2025-09-03 08:55:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-03 08:55:09 -0700 |
commit | 6c8e9fd8c9944a5cd83147b845cb58abe5280316 (patch) | |
tree | c775dec48dcfe7fa4836ae03e3ed860c18e38c89 | |
parent | fd7b1292b8ba1d7ef847ea7084dcf237252753cb (diff) | |
download | voidsky-6c8e9fd8c9944a5cd83147b845cb58abe5280316.tar.zst |
add cursor constraint to safelink (#8966)
-rw-r--r-- | bskylink/src/db/migrations/003-safelink-cursor-constraint.ts | 31 | ||||
-rw-r--r-- | bskylink/src/db/migrations/index.ts | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/bskylink/src/db/migrations/003-safelink-cursor-constraint.ts b/bskylink/src/db/migrations/003-safelink-cursor-constraint.ts new file mode 100644 index 000000000..1607eabeb --- /dev/null +++ b/bskylink/src/db/migrations/003-safelink-cursor-constraint.ts @@ -0,0 +1,31 @@ +import {type Kysely} from 'kysely' + +export async function up( + db: Kysely<{safelink_rule: {}; safelink_cursor: {}}>, +): Promise<void> { + // Remove existing items from safelink_rule that were duplicated due to broken cursor + await db.deleteFrom(['safelink_rule']).execute() + + // Delete the old cursor + await db.deleteFrom(['safelink_cursor']).execute() + + await db.schema + .alterTable('safelink_cursor') + .addPrimaryKeyConstraint('pk_id', ['id']) + .execute() +} + +export async function down( + db: Kysely<{safelink_rule: {}; safelink_cursor: {}}>, +): Promise<void> { + // Remove any rules that were added + await db.deleteFrom(['safelink_rule']).execute() + + // Delete the cursor + await db.deleteFrom(['safelink_cursor']).execute() + + await db.schema + .alterTable('safelink_cursor') + .dropConstraint('pk_id') + .execute() +} diff --git a/bskylink/src/db/migrations/index.ts b/bskylink/src/db/migrations/index.ts index 1f7385ab1..7a34b1001 100644 --- a/bskylink/src/db/migrations/index.ts +++ b/bskylink/src/db/migrations/index.ts @@ -1,7 +1,9 @@ import * as init from './001-init.js' import * as safelink from './002-safelink.js' +import * as safelinkCursorConstraint from './003-safelink-cursor-constraint.js' export default { '001': init, '002': safelink, + '003': safelinkCursorConstraint, } |