···11-CREATE TABLE "test" (
22- "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),
33- "name" varchar NOT NULL
44-);
+33
drizzle/0000_yielding_psylocke.sql
···11+CREATE TABLE "record_pokes" (
22+ "id" serial PRIMARY KEY NOT NULL,
33+ "recordId" integer,
44+ "pokersRepo" text NOT NULL,
55+ "atUri" text NOT NULL,
66+ "indexedAt" time DEFAULT now() NOT NULL
77+);
88+--> statement-breakpoint
99+CREATE TABLE "records" (
1010+ "id" serial PRIMARY KEY NOT NULL,
1111+ "rkey" varchar NOT NULL,
1212+ "collection" varchar NOT NULL,
1313+ "repo" varchar NOT NULL,
1414+ "data" jsonb NOT NULL,
1515+ "indexedAt" time DEFAULT now() NOT NULL
1616+);
1717+--> statement-breakpoint
1818+CREATE TABLE "user_pokes" (
1919+ "id" serial PRIMARY KEY NOT NULL,
2020+ "subject" text NOT NULL,
2121+ "poker" text NOT NULL,
2222+ "at_uri" text NOT NULL,
2323+ "indexedAt" time DEFAULT now() NOT NULL
2424+);
2525+--> statement-breakpoint
2626+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
2727+CREATE INDEX "pokers_repo_idx" ON "record_pokes" USING btree ("pokersRepo");--> statement-breakpoint
2828+CREATE INDEX "at_uri_idx" ON "record_pokes" USING btree ("atUri");--> statement-breakpoint
2929+CREATE INDEX "rkey_idx" ON "records" USING btree ("rkey");--> statement-breakpoint
3030+CREATE INDEX "collection_idx" ON "records" USING btree ("collection");--> statement-breakpoint
3131+CREATE INDEX "repo_idx" ON "records" USING btree ("repo");--> statement-breakpoint
3232+CREATE INDEX "subject_idx" ON "user_pokes" USING btree ("subject");--> statement-breakpoint
3333+CREATE INDEX "poker_idx" ON "user_pokes" USING btree ("poker");
···11-import { integer, pgTable, varchar } from 'drizzle-orm/pg-core';
11+import { index, text, integer, jsonb, pgTable, serial, time, varchar } from 'drizzle-orm/pg-core';
22+33+/**
44+ * Holds collected records from firehose, backfilled, or manually entered
55+ */
66+export const recordsTable = pgTable('records', {
77+ id: serial().primaryKey(),
88+ rkey: varchar().notNull(),
99+ collection: varchar().notNull(),
1010+ repo: varchar().notNull(),
1111+ data: jsonb().notNull(),
1212+ indexedAt: time().notNull().defaultNow()
1313+}, (table) => [
1414+ index('rkey_idx').on(table.rkey),
1515+ index('collection_idx').on(table.collection),
1616+ index('repo_idx').on(table.repo),
1717+]);
1818+21933-export const usersTable = pgTable('test', {
44- id: integer().primaryKey().generatedAlwaysAsIdentity(),
55- name: varchar().notNull(),
66-});
2020+/**
2121+ * Holds pokes toward a record. Current thinking is when a user pokes a record it adds it to the "feeds"
2222+ * Maybe have a "catch all feed" that shows all lexicons that the user wants to see
2323+ *
2424+ * these are the xyz.atpoke.feed.poke records
2525+ */
2626+export const recordPokesTable = pgTable('record_pokes',{
2727+ id: serial().primaryKey(),
2828+ recordId: integer().references(() => recordsTable.id),
2929+ pokersRepo: text().notNull(),
3030+ atUri: text().notNull(),
3131+ indexedAt: time().notNull().defaultNow()
3232+},(table) => [
3333+ index('pokers_repo_idx').on(table.pokersRepo),
3434+ index('at_uri_idx').on(table.atUri)
3535+]);
7363737+/**
3838+ * These are the traditional pokes. Like "I just poked user xyz". These will make it to the feed via recordsTable
3939+ *
4040+ * xyz.atpoke.graph.poke
4141+ */
4242+export const userPokes = pgTable('user_pokes', {
4343+ id: serial().primaryKey(),
4444+ //This is who you poked
4545+ subject: text().notNull(),
4646+ //Who is doing the poking
4747+ poker: text().notNull(),
4848+ at_uri: text().notNull(),
4949+ indexedAt: time().notNull().defaultNow()
5050+}, (table) => [
5151+ index('subject_idx').on(table.subject),
5252+ index('poker_idx').on(table.poker)
5353+]);
85499-// export const keyValueStore = sqliteTable('key_value_store', {
1010-// key: p text('key').primaryKey(),
1111-// value: text('value'),
1212-// storeName: text('storeName'),
1313-// createdAt: integer({ mode: 'timestamp' }) // Date
1414-// });
1515-//
1616-//
1717-// export const sessionStore = sqliteTable('session_store', {
1818-// id: text('id').primaryKey(),
1919-// //Not leaving unique since it could be multiple logins from the same user across browsers
2020-// did: text('did').notNull(),
2121-// handle: text('handle').notNull(),
2222-// createdAt: integer({ mode: 'timestamp' }).notNull(), // Date
2323-// expiresAt: integer({ mode: 'timestamp' }).notNull() // Date
2424-//
2525-// });