Skip to content

Commit

Permalink
update schema to deal with >int firehose seq
Browse files Browse the repository at this point in the history
  • Loading branch information
Bossett committed Oct 2, 2024
1 parent 4dbc908 commit cb85853
Show file tree
Hide file tree
Showing 17 changed files with 214 additions and 1,064 deletions.
1 change: 1 addition & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Config } from 'drizzle-kit'

export default {
dialect: 'postgresql',
schema: './src/db/schema.ts',
out: './drizzle',
} satisfies Config
13 changes: 0 additions & 13 deletions drizzle/0000_volatile_doctor_spectrum.sql

This file was deleted.

39 changes: 39 additions & 0 deletions drizzle/0000_white_living_mummy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS "label_actions" (
"id" bigserial PRIMARY KEY NOT NULL,
"label" text NOT NULL,
"action" text NOT NULL,
"did" text NOT NULL,
"comment" text,
"unixtimescheduled" bigint DEFAULT 0
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "listItems" (
"id" bigserial NOT NULL,
"did" text NOT NULL,
"listURLId" bigint NOT NULL,
"listItemURL" text,
"unixtimeDeleted" bigint,
CONSTRAINT "listItems_did_listURLId_pk" PRIMARY KEY("did","listURLId"),
CONSTRAINT "listItems_id_unique" UNIQUE("id")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "lists" (
"id" bigserial PRIMARY KEY NOT NULL,
"label" text NOT NULL,
"listURL" text NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "subscription_status" (
"id" bigserial PRIMARY KEY NOT NULL,
"last_sequence" bigint DEFAULT -1 NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "listItems" ADD CONSTRAINT "listItems_listURLId_lists_id_fk" FOREIGN KEY ("listURLId") REFERENCES "public"."lists"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "time_idx" ON "label_actions" USING btree ("unixtimescheduled");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "did_idx" ON "listItems" USING btree ("did");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "id_idx" ON "listItems" USING btree ("id");
20 changes: 0 additions & 20 deletions drizzle/0001_burly_swarm.sql

This file was deleted.

19 changes: 0 additions & 19 deletions drizzle/0002_sleepy_golden_guardian.sql

This file was deleted.

1 change: 0 additions & 1 deletion drizzle/0003_overconfident_blue_marvel.sql

This file was deleted.

1 change: 0 additions & 1 deletion drizzle/0004_amused_juggernaut.sql

This file was deleted.

1 change: 0 additions & 1 deletion drizzle/0005_lonely_spirit.sql

This file was deleted.

164 changes: 155 additions & 9 deletions drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id": "902de2de-053d-4151-86c0-ddc75f6413a0",
"id": "157ecb23-73aa-49bc-a00a-ed19eff0f269",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "5",
"dialect": "pg",
"version": "7",
"dialect": "postgresql",
"tables": {
"label_actions": {
"public.label_actions": {
"name": "label_actions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"type": "bigserial",
"primaryKey": true,
"notNull": true
},
Expand Down Expand Up @@ -40,30 +40,175 @@
},
"unixtimescheduled": {
"name": "unixtimescheduled",
"type": "integer",
"type": "bigint",
"primaryKey": false,
"notNull": false,
"default": 0
}
},
"indexes": {
"time_idx": {
"name": "time_idx",
"columns": [
{
"expression": "unixtimescheduled",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public.listItems": {
"name": "listItems",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "bigserial",
"primaryKey": false,
"notNull": true
},
"did": {
"name": "did",
"type": "text",
"primaryKey": false,
"notNull": true
},
"listURLId": {
"name": "listURLId",
"type": "bigint",
"primaryKey": false,
"notNull": true
},
"listItemURL": {
"name": "listItemURL",
"type": "text",
"primaryKey": false,
"notNull": false
},
"unixtimeDeleted": {
"name": "unixtimeDeleted",
"type": "bigint",
"primaryKey": false,
"notNull": false
}
},
"indexes": {
"did_idx": {
"name": "did_idx",
"columns": [
{
"expression": "did",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
},
"id_idx": {
"name": "id_idx",
"columns": [
{
"expression": "id",
"isExpression": false,
"asc": true,
"nulls": "last"
}
],
"isUnique": false,
"concurrently": false,
"method": "btree",
"with": {}
}
},
"foreignKeys": {
"listItems_listURLId_lists_id_fk": {
"name": "listItems_listURLId_lists_id_fk",
"tableFrom": "listItems",
"tableTo": "lists",
"columnsFrom": [
"listURLId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"listItems_did_listURLId_pk": {
"name": "listItems_did_listURLId_pk",
"columns": [
"did",
"listURLId"
]
}
},
"uniqueConstraints": {
"listItems_id_unique": {
"name": "listItems_id_unique",
"nullsNotDistinct": false,
"columns": [
"id"
]
}
}
},
"public.lists": {
"name": "lists",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "bigserial",
"primaryKey": true,
"notNull": true
},
"label": {
"name": "label",
"type": "text",
"primaryKey": false,
"notNull": true
},
"listURL": {
"name": "listURL",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"subscription_status": {
"public.subscription_status": {
"name": "subscription_status",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"type": "bigserial",
"primaryKey": true,
"notNull": true
},
"last_sequence": {
"name": "last_sequence",
"type": "integer",
"type": "bigint",
"primaryKey": false,
"notNull": true,
"default": -1
Expand All @@ -77,6 +222,7 @@
},
"enums": {},
"schemas": {},
"sequences": {},
"_meta": {
"columns": {},
"schemas": {},
Expand Down
Loading

0 comments on commit cb85853

Please sign in to comment.