inital db

-4
drizzle/0000_nervous_freak.sql
··· 1 - CREATE TABLE "test" ( 2 - "id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "test_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), 3 - "name" varchar NOT NULL 4 - );
+33
drizzle/0000_yielding_psylocke.sql
··· 1 + CREATE TABLE "record_pokes" ( 2 + "id" serial PRIMARY KEY NOT NULL, 3 + "recordId" integer, 4 + "pokersRepo" text NOT NULL, 5 + "atUri" text NOT NULL, 6 + "indexedAt" time DEFAULT now() NOT NULL 7 + ); 8 + --> statement-breakpoint 9 + CREATE TABLE "records" ( 10 + "id" serial PRIMARY KEY NOT NULL, 11 + "rkey" varchar NOT NULL, 12 + "collection" varchar NOT NULL, 13 + "repo" varchar NOT NULL, 14 + "data" jsonb NOT NULL, 15 + "indexedAt" time DEFAULT now() NOT NULL 16 + ); 17 + --> statement-breakpoint 18 + CREATE TABLE "user_pokes" ( 19 + "id" serial PRIMARY KEY NOT NULL, 20 + "subject" text NOT NULL, 21 + "poker" text NOT NULL, 22 + "at_uri" text NOT NULL, 23 + "indexedAt" time DEFAULT now() NOT NULL 24 + ); 25 + --> statement-breakpoint 26 + ALTER TABLE "record_pokes" ADD CONSTRAINT "record_pokes_recordId_records_id_fk" FOREIGN KEY ("recordId") REFERENCES "public"."records"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint 27 + CREATE INDEX "pokers_repo_idx" ON "record_pokes" USING btree ("pokersRepo");--> statement-breakpoint 28 + CREATE INDEX "at_uri_idx" ON "record_pokes" USING btree ("atUri");--> statement-breakpoint 29 + CREATE INDEX "rkey_idx" ON "records" USING btree ("rkey");--> statement-breakpoint 30 + CREATE INDEX "collection_idx" ON "records" USING btree ("collection");--> statement-breakpoint 31 + CREATE INDEX "repo_idx" ON "records" USING btree ("repo");--> statement-breakpoint 32 + CREATE INDEX "subject_idx" ON "user_pokes" USING btree ("subject");--> statement-breakpoint 33 + CREATE INDEX "poker_idx" ON "user_pokes" USING btree ("poker");
+242 -18
drizzle/meta/0000_snapshot.json
··· 1 1 { 2 - "id": "b5b82b54-3237-45a5-b53d-72f531d83653", 2 + "id": "eb652b7e-c43a-411e-9e94-15bfb4be773f", 3 3 "prevId": "00000000-0000-0000-0000-000000000000", 4 4 "version": "7", 5 5 "dialect": "postgresql", 6 6 "tables": { 7 - "public.test": { 8 - "name": "test", 7 + "public.record_pokes": { 8 + "name": "record_pokes", 9 9 "schema": "", 10 10 "columns": { 11 11 "id": { 12 12 "name": "id", 13 + "type": "serial", 14 + "primaryKey": true, 15 + "notNull": true 16 + }, 17 + "recordId": { 18 + "name": "recordId", 13 19 "type": "integer", 14 - "primaryKey": true, 20 + "primaryKey": false, 21 + "notNull": false 22 + }, 23 + "pokersRepo": { 24 + "name": "pokersRepo", 25 + "type": "text", 26 + "primaryKey": false, 27 + "notNull": true 28 + }, 29 + "atUri": { 30 + "name": "atUri", 31 + "type": "text", 32 + "primaryKey": false, 33 + "notNull": true 34 + }, 35 + "indexedAt": { 36 + "name": "indexedAt", 37 + "type": "time", 38 + "primaryKey": false, 15 39 "notNull": true, 16 - "identity": { 17 - "type": "always", 18 - "name": "test_id_seq", 19 - "schema": "public", 20 - "increment": "1", 21 - "startWith": "1", 22 - "minValue": "1", 23 - "maxValue": "2147483647", 24 - "cache": "1", 25 - "cycle": false 26 - } 40 + "default": "now()" 41 + } 42 + }, 43 + "indexes": { 44 + "pokers_repo_idx": { 45 + "name": "pokers_repo_idx", 46 + "columns": [ 47 + { 48 + "expression": "pokersRepo", 49 + "isExpression": false, 50 + "asc": true, 51 + "nulls": "last" 52 + } 53 + ], 54 + "isUnique": false, 55 + "concurrently": false, 56 + "method": "btree", 57 + "with": {} 27 58 }, 28 - "name": { 29 - "name": "name", 59 + "at_uri_idx": { 60 + "name": "at_uri_idx", 61 + "columns": [ 62 + { 63 + "expression": "atUri", 64 + "isExpression": false, 65 + "asc": true, 66 + "nulls": "last" 67 + } 68 + ], 69 + "isUnique": false, 70 + "concurrently": false, 71 + "method": "btree", 72 + "with": {} 73 + } 74 + }, 75 + "foreignKeys": { 76 + "record_pokes_recordId_records_id_fk": { 77 + "name": "record_pokes_recordId_records_id_fk", 78 + "tableFrom": "record_pokes", 79 + "tableTo": "records", 80 + "columnsFrom": [ 81 + "recordId" 82 + ], 83 + "columnsTo": [ 84 + "id" 85 + ], 86 + "onDelete": "no action", 87 + "onUpdate": "no action" 88 + } 89 + }, 90 + "compositePrimaryKeys": {}, 91 + "uniqueConstraints": {}, 92 + "policies": {}, 93 + "checkConstraints": {}, 94 + "isRLSEnabled": false 95 + }, 96 + "public.records": { 97 + "name": "records", 98 + "schema": "", 99 + "columns": { 100 + "id": { 101 + "name": "id", 102 + "type": "serial", 103 + "primaryKey": true, 104 + "notNull": true 105 + }, 106 + "rkey": { 107 + "name": "rkey", 30 108 "type": "varchar", 31 109 "primaryKey": false, 32 110 "notNull": true 111 + }, 112 + "collection": { 113 + "name": "collection", 114 + "type": "varchar", 115 + "primaryKey": false, 116 + "notNull": true 117 + }, 118 + "repo": { 119 + "name": "repo", 120 + "type": "varchar", 121 + "primaryKey": false, 122 + "notNull": true 123 + }, 124 + "data": { 125 + "name": "data", 126 + "type": "jsonb", 127 + "primaryKey": false, 128 + "notNull": true 129 + }, 130 + "indexedAt": { 131 + "name": "indexedAt", 132 + "type": "time", 133 + "primaryKey": false, 134 + "notNull": true, 135 + "default": "now()" 33 136 } 34 137 }, 35 - "indexes": {}, 138 + "indexes": { 139 + "rkey_idx": { 140 + "name": "rkey_idx", 141 + "columns": [ 142 + { 143 + "expression": "rkey", 144 + "isExpression": false, 145 + "asc": true, 146 + "nulls": "last" 147 + } 148 + ], 149 + "isUnique": false, 150 + "concurrently": false, 151 + "method": "btree", 152 + "with": {} 153 + }, 154 + "collection_idx": { 155 + "name": "collection_idx", 156 + "columns": [ 157 + { 158 + "expression": "collection", 159 + "isExpression": false, 160 + "asc": true, 161 + "nulls": "last" 162 + } 163 + ], 164 + "isUnique": false, 165 + "concurrently": false, 166 + "method": "btree", 167 + "with": {} 168 + }, 169 + "repo_idx": { 170 + "name": "repo_idx", 171 + "columns": [ 172 + { 173 + "expression": "repo", 174 + "isExpression": false, 175 + "asc": true, 176 + "nulls": "last" 177 + } 178 + ], 179 + "isUnique": false, 180 + "concurrently": false, 181 + "method": "btree", 182 + "with": {} 183 + } 184 + }, 185 + "foreignKeys": {}, 186 + "compositePrimaryKeys": {}, 187 + "uniqueConstraints": {}, 188 + "policies": {}, 189 + "checkConstraints": {}, 190 + "isRLSEnabled": false 191 + }, 192 + "public.user_pokes": { 193 + "name": "user_pokes", 194 + "schema": "", 195 + "columns": { 196 + "id": { 197 + "name": "id", 198 + "type": "serial", 199 + "primaryKey": true, 200 + "notNull": true 201 + }, 202 + "subject": { 203 + "name": "subject", 204 + "type": "text", 205 + "primaryKey": false, 206 + "notNull": true 207 + }, 208 + "poker": { 209 + "name": "poker", 210 + "type": "text", 211 + "primaryKey": false, 212 + "notNull": true 213 + }, 214 + "at_uri": { 215 + "name": "at_uri", 216 + "type": "text", 217 + "primaryKey": false, 218 + "notNull": true 219 + }, 220 + "indexedAt": { 221 + "name": "indexedAt", 222 + "type": "time", 223 + "primaryKey": false, 224 + "notNull": true, 225 + "default": "now()" 226 + } 227 + }, 228 + "indexes": { 229 + "subject_idx": { 230 + "name": "subject_idx", 231 + "columns": [ 232 + { 233 + "expression": "subject", 234 + "isExpression": false, 235 + "asc": true, 236 + "nulls": "last" 237 + } 238 + ], 239 + "isUnique": false, 240 + "concurrently": false, 241 + "method": "btree", 242 + "with": {} 243 + }, 244 + "poker_idx": { 245 + "name": "poker_idx", 246 + "columns": [ 247 + { 248 + "expression": "poker", 249 + "isExpression": false, 250 + "asc": true, 251 + "nulls": "last" 252 + } 253 + ], 254 + "isUnique": false, 255 + "concurrently": false, 256 + "method": "btree", 257 + "with": {} 258 + } 259 + }, 36 260 "foreignKeys": {}, 37 261 "compositePrimaryKeys": {}, 38 262 "uniqueConstraints": {},
+2 -2
drizzle/meta/_journal.json
··· 5 5 { 6 6 "idx": 0, 7 7 "version": "7", 8 - "when": 1765827212209, 9 - "tag": "0000_nervous_freak", 8 + "when": 1766032962283, 9 + "tag": "0000_yielding_psylocke", 10 10 "breakpoints": true 11 11 } 12 12 ]
+51 -22
src/lib/server/db/schema.ts
··· 1 - import { integer, pgTable, varchar } from 'drizzle-orm/pg-core'; 1 + import { index, text, integer, jsonb, pgTable, serial, time, varchar } from 'drizzle-orm/pg-core'; 2 + 3 + /** 4 + * Holds collected records from firehose, backfilled, or manually entered 5 + */ 6 + export const recordsTable = pgTable('records', { 7 + id: serial().primaryKey(), 8 + rkey: varchar().notNull(), 9 + collection: varchar().notNull(), 10 + repo: varchar().notNull(), 11 + data: jsonb().notNull(), 12 + indexedAt: time().notNull().defaultNow() 13 + }, (table) => [ 14 + index('rkey_idx').on(table.rkey), 15 + index('collection_idx').on(table.collection), 16 + index('repo_idx').on(table.repo), 17 + ]); 18 + 2 19 3 - export const usersTable = pgTable('test', { 4 - id: integer().primaryKey().generatedAlwaysAsIdentity(), 5 - name: varchar().notNull(), 6 - }); 20 + /** 21 + * Holds pokes toward a record. Current thinking is when a user pokes a record it adds it to the "feeds" 22 + * Maybe have a "catch all feed" that shows all lexicons that the user wants to see 23 + * 24 + * these are the xyz.atpoke.feed.poke records 25 + */ 26 + export const recordPokesTable = pgTable('record_pokes',{ 27 + id: serial().primaryKey(), 28 + recordId: integer().references(() => recordsTable.id), 29 + pokersRepo: text().notNull(), 30 + atUri: text().notNull(), 31 + indexedAt: time().notNull().defaultNow() 32 + },(table) => [ 33 + index('pokers_repo_idx').on(table.pokersRepo), 34 + index('at_uri_idx').on(table.atUri) 35 + ]); 7 36 37 + /** 38 + * These are the traditional pokes. Like "I just poked user xyz". These will make it to the feed via recordsTable 39 + * 40 + * xyz.atpoke.graph.poke 41 + */ 42 + export const userPokes = pgTable('user_pokes', { 43 + id: serial().primaryKey(), 44 + //This is who you poked 45 + subject: text().notNull(), 46 + //Who is doing the poking 47 + poker: text().notNull(), 48 + at_uri: text().notNull(), 49 + indexedAt: time().notNull().defaultNow() 50 + }, (table) => [ 51 + index('subject_idx').on(table.subject), 52 + index('poker_idx').on(table.poker) 53 + ]); 8 54 9 - // export const keyValueStore = sqliteTable('key_value_store', { 10 - // key: p text('key').primaryKey(), 11 - // value: text('value'), 12 - // storeName: text('storeName'), 13 - // createdAt: integer({ mode: 'timestamp' }) // Date 14 - // }); 15 - // 16 - // 17 - // export const sessionStore = sqliteTable('session_store', { 18 - // id: text('id').primaryKey(), 19 - // //Not leaving unique since it could be multiple logins from the same user across browsers 20 - // did: text('did').notNull(), 21 - // handle: text('handle').notNull(), 22 - // createdAt: integer({ mode: 'timestamp' }).notNull(), // Date 23 - // expiresAt: integer({ mode: 'timestamp' }).notNull() // Date 24 - // 25 - // });