@respectify/astro 0.2.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,49 +16,102 @@ Built for production — powers [nickhodges.com](https://nickhodges.com) as a li
16
16
  - **Works with prerendered pages** — comments load at runtime via API; no rebuild needed
17
17
  - **One component** — `<CommentSection postSlug="..." />`
18
18
  - **Powered by Respectify branding** — optional callout and badge for demos
19
- - **Astro DB storage** — Turso/libSQL via `@astrojs/db`
19
+ - **Your database** — Postgres or SQLite/libSQL (Turso) through your own [Drizzle](https://orm.drizzle.team) connection, or any store you write against `ICommentStore`
20
+ - **Never touches your schema** — the package ships table definitions and drizzle-kit migrations; you decide when they run
20
21
  - **Self-contained CSS** — no Tailwind required; customize via CSS variables
21
22
  - **Fail-closed** — rejects comments when Respectify is unavailable
22
23
 
23
24
  ## Requirements
24
25
 
25
- - Astro 5 or 6 with **`output: 'server'`** (or hybrid) and a server adapter (Vercel, Node, etc.)
26
- - [`@astrojs/db`](https://docs.astro.build/en/guides/astro-db/) configured with Turso for production
26
+ - Astro 5, 6 or 7 with **`output: 'server'`** (or hybrid) and a server adapter (Vercel, Node, etc.)
27
+ - A database you reach through Drizzle ORM (`drizzle-orm` 0.45): Postgres (node-postgres, postgres.js, Neon, PGlite, …) or SQLite (libSQL/Turso, better-sqlite3, Cloudflare D1, …)
27
28
  - A [Respectify](https://respectify.ai) account (`RESPECTIFY_EMAIL` + `RESPECTIFY_API_KEY`)
28
29
 
29
- > Prefer API-only moderation without Astro DB / comment UI? Use [`@respectify/client`](https://www.npmjs.com/package/@respectify/client) instead. See [Choose your TypeScript path](https://respectify.ai/comment-moderation-api#paths).
30
+ > Upgrading from 0.x, which stored comments through Astro DB? See [Migrating from 0.x (Astro DB)](#migrating-from-0x-astro-db).
31
+ >
32
+ > Prefer API-only moderation without a comment UI or database? Use [`@respectify/astro-moderation`](https://www.npmjs.com/package/@respectify/astro-moderation) or [`@respectify/client`](https://www.npmjs.com/package/@respectify/client).
30
33
 
31
34
  ## Quick start
32
35
 
33
36
  ### 1. Install
34
37
 
38
+ Install the package, Drizzle, and the driver for your database. For Postgres with node-postgres:
39
+
40
+ ```bash
41
+ npm install @respectify/astro @respectify/client drizzle-orm pg
42
+ npm install -D drizzle-kit @types/pg
43
+ ```
44
+
45
+ For libSQL/Turso, install `@libsql/client` instead of `pg`. The package never installs a driver itself: `pg` and `@libsql/client` are optional peer dependencies, so you only get the one you use.
46
+
47
+ ### 2. Add the comment table and migrate
48
+
49
+ Add the table to your Drizzle schema:
50
+
51
+ ```ts
52
+ // src/db/schema.ts
53
+ export { respectifyComments } from '@respectify/astro/postgres'; // or '@respectify/astro/sqlite'
54
+ ```
55
+
56
+ Then generate and run the migration with drizzle-kit, the way you migrate the rest of your schema:
57
+
35
58
  ```bash
36
- npm install @respectify/astro @respectify/client @astrojs/db
59
+ npx drizzle-kit generate
60
+ npx drizzle-kit migrate
61
+ ```
62
+
63
+ The tables are named `respectify_comment` (Postgres) and `Comment` (SQLite). For another name, use `createPostgresCommentTable('my_comments')` or `createSqliteCommentTable('my_comments')` and pass the table to the store. If you manage your schema some other way, the SQL drizzle-kit generates for the default tables is in [`migrations/postgres`](./migrations/postgres) and [`migrations/sqlite`](./migrations/sqlite).
64
+
65
+ The integration never creates, alters or migrates a table.
66
+
67
+ ### 3. Write the runtime module
68
+
69
+ The store, and any functions, live in a module that runs inside your server bundle, so they use the connection your site already has:
70
+
71
+ ```ts
72
+ // src/respectify.runtime.ts
73
+ import { defineRespectifyRuntime } from '@respectify/astro';
74
+ import { createPostgresCommentStore } from '@respectify/astro/postgres';
75
+ import { drizzle } from 'drizzle-orm/node-postgres';
76
+ import { Pool } from 'pg';
77
+ import { DATABASE_URL } from 'astro:env/server';
78
+
79
+ const db = drizzle({ client: new Pool({ connectionString: DATABASE_URL }) });
80
+
81
+ export default defineRespectifyRuntime({
82
+ store: createPostgresCommentStore(db),
83
+ // Optional: the canonical URL Respectify reads a post from for topic context
84
+ getPostUrl: (slug, site) => `${site}/blog/${slug}/`,
85
+ });
37
86
  ```
38
87
 
39
- ### 2. Add the integration
88
+ For SQLite, use `createSqliteCommentStore(db)` from `@respectify/astro/sqlite` with your Drizzle SQLite database (for libSQL/Turso, `drizzle({ client: createClient({ url, authToken }) })` from `drizzle-orm/libsql`).
89
+
90
+ ### 4. Add the integration
40
91
 
41
92
  ```ts
42
93
  // astro.config.ts
43
- import { defineConfig } from 'astro/config';
44
- import db from '@astrojs/db';
94
+ import { defineConfig, envField } from 'astro/config';
45
95
  import respectify from '@respectify/astro';
46
96
 
47
97
  export default defineConfig({
48
98
  site: 'https://yoursite.com',
49
99
  output: 'server',
50
100
  adapter: vercel(), // or node, netlify, etc.
101
+ env: {
102
+ schema: {
103
+ DATABASE_URL: envField.string({ context: 'server', access: 'secret' }),
104
+ },
105
+ },
51
106
  integrations: [
52
- db(),
53
107
  respectify({
54
- // Optional: customize post URL for Respectify topic context
55
- getPostUrl: (slug, site) => `${site}/blog/${slug}/`,
108
+ runtime: './src/respectify.runtime.ts',
56
109
  }),
57
110
  ],
58
111
  });
59
112
  ```
60
113
 
61
- ### 3. Configure Respectify
114
+ ### 5. Configure Respectify
62
115
 
63
116
  Copy a starter config to your project root:
64
117
 
@@ -77,53 +130,10 @@ Add environment variables:
77
130
  ```env
78
131
  RESPECTIFY_EMAIL=you@example.com
79
132
  RESPECTIFY_API_KEY=your-api-key
80
- ASTRO_DB_REMOTE_URL=libsql://...
81
- ASTRO_DB_APP_TOKEN=...
82
- ```
83
-
84
- ### 4. Add the database table
85
-
86
- Copy this into `db/config.ts` (or import from `@respectify/astro/schema` if your setup supports it):
87
-
88
- ```ts
89
- import { defineDb, defineTable, column, NOW } from 'astro:db';
90
-
91
- const Comment = defineTable({
92
- columns: {
93
- id: column.number({ primaryKey: true }),
94
- postSlug: column.text(),
95
- author: column.text(),
96
- email: column.text({ optional: true }),
97
- content: column.text(),
98
- createdAt: column.date({ default: NOW }),
99
- approved: column.boolean({ default: false }),
100
- parentId: column.number({ optional: true }),
101
- },
102
- indexes: [
103
- { on: ['postSlug'], unique: false },
104
- { on: ['approved'], unique: false },
105
- ],
106
- });
107
-
108
- export default defineDb({ tables: { Comment } });
133
+ DATABASE_URL=postgres://...
109
134
  ```
110
135
 
111
- Or use the exported helper:
112
-
113
- ```ts
114
- import { defineDb } from 'astro:db';
115
- import { Comment } from '@respectify/astro/schema';
116
-
117
- export default defineDb({ tables: { Comment } });
118
- ```
119
-
120
- Run migrations:
121
-
122
- ```bash
123
- npx astro db push
124
- ```
125
-
126
- ### 5. Wire up Astro Actions
136
+ ### 6. Wire up Astro Actions
127
137
 
128
138
  ```ts
129
139
  // src/actions/index.ts
@@ -134,7 +144,7 @@ export const server = {
134
144
  };
135
145
  ```
136
146
 
137
- ### 6. Add comments to your layout
147
+ ### 7. Add comments to your layout
138
148
 
139
149
  ```astro
140
150
  ---
@@ -146,6 +156,42 @@ import CommentSection from '@respectify/astro/components/CommentSection.astro';
146
156
 
147
157
  That's it. Comments are moderated by Respectify before they appear.
148
158
 
159
+ ## Storage
160
+
161
+ The actions, the comments API route and the moderation service depend only on the `ICommentStore` interface:
162
+
163
+ ```ts
164
+ interface ICommentStore {
165
+ findById(id: number): Promise<CommentRecord | undefined>;
166
+ listApproved(postSlug: string): Promise<PublicComment[]>; // oldest first, ties by id
167
+ create(input: NewComment): Promise<CommentRecord>; // validates with newCommentSchema
168
+ delete(id: number): Promise<boolean>; // replies are kept, with parentId null
169
+ }
170
+ ```
171
+
172
+ | Store | Import | Works with |
173
+ | --- | --- | --- |
174
+ | `createPostgresCommentStore(db, { table? })` | `@respectify/astro/postgres` | Any Drizzle Postgres database: node-postgres, postgres.js, Neon, PGlite, … |
175
+ | `createSqliteCommentStore(db, { table? })` | `@respectify/astro/sqlite` | Any Drizzle SQLite database: libSQL/Turso, better-sqlite3, Cloudflare D1, … |
176
+
177
+ Both take your Drizzle database instance and never open a connection of their own.
178
+
179
+ ### Writing your own store
180
+
181
+ Implement `ICommentStore` (types from `@respectify/astro`) and run the shared contract suite, which every built-in store passes, against it with Vitest:
182
+
183
+ ```ts
184
+ // test/my-comment-store.test.ts
185
+ import { describeCommentStoreContract } from '@respectify/astro/testing';
186
+
187
+ describeCommentStoreContract('my store', async () => ({
188
+ store: createMyCommentStore(await createEmptyTestDatabase()),
189
+ dispose: () => closeTestDatabase(),
190
+ }));
191
+ ```
192
+
193
+ The factory must return a store on a new, empty table each time.
194
+
149
195
  ## Component props
150
196
 
151
197
  | Prop | Default | Description |
@@ -172,25 +218,23 @@ Override on `.rf-comments`:
172
218
 
173
219
  ### Integration options
174
220
 
175
- Any `@respectify/client` option can be set via `client` and `megacall`. Values in `astro.config` override the same keys in `respectify.config.json`.
221
+ `respectify()` takes only values that can be serialized, because Astro runs `astro.config` apart from your server bundle. Functions go in the runtime module. Any `@respectify/client` option can be set via `client` and `megacall`. Values in `astro.config` override the same keys in `respectify.config.json`.
176
222
 
177
223
  ```ts
178
224
  respectify({
225
+ // Required: the module whose default export is defineRespectifyRuntime({ store, ... })
226
+ runtime: './src/respectify.runtime.ts',
227
+
179
228
  configPath: './respectify.config.json',
180
229
  commentsApiPath: '/api/respectify/comments',
181
230
  showBranding: true,
182
- getPostUrl: (slug, site) => `${site}/posts/${slug}/`,
183
-
184
- // Alternative to getPostUrl: hand Respectify the post body directly instead of
185
- // having it fetch getPostUrl. Useful for staged/preview/auth-gated content, or
186
- // when the URL isn't live yet right after deploy. Takes priority over getPostUrl.
187
- // getPostContent: async (slug) => loadPostBody(slug),
188
231
 
189
232
  // Per-IP submission limit, enforced in the `comments.submit` action.
190
233
  // In-memory per server process — not shared across multiple instances/regions.
191
234
  rateLimit: { windowMs: 300_000, maxRequests: 10 },
192
235
 
193
- // Forwarded to RespectifyClient (email/apiKey still default from env)
236
+ // Forwarded to RespectifyClient. Credentials are not accepted here, since these options are
237
+ // written into the server bundle: use RESPECTIFY_EMAIL / RESPECTIFY_API_KEY
194
238
  client: {
195
239
  baseUrl: 'https://app.respectify.ai',
196
240
  timeout: 30_000,
@@ -215,6 +259,20 @@ respectify({
215
259
  });
216
260
  ```
217
261
 
262
+ The runtime module takes the store and the two optional post functions:
263
+
264
+ ```ts
265
+ export default defineRespectifyRuntime({
266
+ store,
267
+ // The canonical URL for a post, used to initialize Respectify topics (default: `${site}/posts/${slug}/`)
268
+ getPostUrl: (slug, site) => `${site}/posts/${slug}/`,
269
+ // Alternative to getPostUrl: hand Respectify the post body directly instead of having it
270
+ // fetch getPostUrl. Useful for staged/preview/auth-gated content, or when the URL isn't
271
+ // live yet right after deploy. Takes priority over getPostUrl.
272
+ getPostContent: async (slug) => loadPostBody(slug),
273
+ });
274
+ ```
275
+
218
276
  `showBranding` and `commentsApiPath` set here become the defaults for `<CommentSection>` — you can still override either per-instance via props.
219
277
 
220
278
  ### Checking Respectify credentials
@@ -225,7 +283,7 @@ import { verifyRespectifyCredentials } from '@respectify/astro/credentials';
225
283
  const isConnected = await verifyRespectifyCredentials();
226
284
  ```
227
285
 
228
- Useful for an admin health-check page — returns `true` when `RESPECTIFY_EMAIL`/`RESPECTIFY_API_KEY` (or `client.email`/`client.apiKey`) are valid and the subscription is active.
286
+ Useful for an admin health-check page — returns `true` when `RESPECTIFY_EMAIL`/`RESPECTIFY_API_KEY` (or `client.email`/`client.apiKey` in `respectify.config.json`) are valid and the subscription is active.
229
287
 
230
288
  ### `respectify.config.json`
231
289
 
@@ -275,12 +333,64 @@ Set `enableDelete` on `CommentSection` and implement auth so `context.locals.isA
275
333
  Visitor submits comment
276
334
  → Astro Action (comments.submit)
277
335
  → Respectify megacall (configured checks: spam, score, relevance, dogwhistle, …)
278
- → If approved: save to Astro DB
279
- → Client refreshes comment list via GET /api/respectify/comments
336
+ → If approved: store.create() saves it through your ICommentStore
337
+ → Client refreshes comment list via GET /api/respectify/comments (store.listApproved())
280
338
  ```
281
339
 
282
340
  Post pages can stay `prerender = true`. Only the API route and actions need server runtime.
283
341
 
342
+ ## Migrating from 0.x (Astro DB)
343
+
344
+ 1.0 removes Astro DB, which Astro deprecated in 6.4 and removed in 7.0, so it is a breaking release. What changes:
345
+
346
+ | 0.x | 1.0 |
347
+ | --- | --- |
348
+ | `@astrojs/db` peer dependency, `db()` integration, `db/config.ts` | Your own Drizzle database, passed to a store in a runtime module |
349
+ | `@respectify/astro/schema` | `@respectify/astro/sqlite` or `@respectify/astro/postgres` (`respectifyComments`) |
350
+ | `getPostUrl` / `getPostContent` in `respectify({...})` | In `defineRespectifyRuntime({...})`; passing them to `respectify()` now fails at startup |
351
+ | `astro db push`, `astro build --remote` | drizzle-kit (or your own migrations); plain `astro build` |
352
+ | `ASTRO_DB_REMOTE_URL`, `ASTRO_DB_APP_TOKEN` | Your own variables, declared with `astro:env` |
353
+ | `client.email` / `client.apiKey` in `respectify({...})` | `RESPECTIFY_EMAIL` / `RESPECTIFY_API_KEY` (or `respectify.config.json`); in `astro.config` they now fail at startup |
354
+ | `comments.delete` of a missing comment succeeded | Fails with `NOT_FOUND`; a reply to a missing comment, or one on another post, fails with `BAD_REQUEST` |
355
+ | Comments API returns `id, author, content, createdAt` | Adds `parentId` |
356
+
357
+ 0.x also lost every `respectify()` option at runtime in production builds (they were kept in module state that never reached the server bundle), so `getPostUrl`, `tolerances`, `rateLimit`, `client` and `megacall` silently fell back to their defaults. 1.0 passes them to the server bundle through a virtual module. If you had set them, review them: they now take effect.
358
+
359
+ ### Keep your Turso database (no data to move)
360
+
361
+ The SQLite store's default table is exactly the `Comment` table Astro DB created (same columns, defaults, index names and date format), so your existing comments are used as they are.
362
+
363
+ 1. `npm uninstall @astrojs/db` and `npm install drizzle-orm @libsql/client`.
364
+ 2. Remove `db()` from `astro.config` and delete `db/config.ts`. Drop `--remote` from your build script.
365
+ 3. Declare the Turso URL and token in `astro.config`'s `env.schema` (they can keep their names), and write the runtime module:
366
+
367
+ ```ts
368
+ // src/respectify.runtime.ts
369
+ import { defineRespectifyRuntime } from '@respectify/astro';
370
+ import { createSqliteCommentStore } from '@respectify/astro/sqlite';
371
+ import { createClient } from '@libsql/client';
372
+ import { drizzle } from 'drizzle-orm/libsql';
373
+ import { ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN } from 'astro:env/server';
374
+
375
+ const db = drizzle({ client: createClient({ url: ASTRO_DB_REMOTE_URL, authToken: ASTRO_DB_APP_TOKEN }) });
376
+
377
+ export default defineRespectifyRuntime({ store: createSqliteCommentStore(db) });
378
+ ```
379
+
380
+ 4. Change `respectify({ ... })` to `respectify({ runtime: './src/respectify.runtime.ts', ... })`, moving any `getPostUrl` / `getPostContent` into the runtime module.
381
+
382
+ Do **not** run the reference migration in `migrations/sqlite` against this database: the table already exists. If you manage the rest of the database with drizzle-kit, take the table in with `drizzle-kit pull` first, or mark the migration as applied. drizzle-kit marks the `id` column `NOT NULL` where Astro DB did not; for an `INTEGER PRIMARY KEY` in SQLite that makes no difference, so there is nothing to change.
383
+
384
+ ### Move your comments to Postgres
385
+
386
+ 1. Create the table in Postgres: add `respectifyComments` from `@respectify/astro/postgres` to your Drizzle schema and run drizzle-kit (or apply [`migrations/postgres`](./migrations/postgres)).
387
+ 2. Copy the rows from Turso with Drizzle, reading through `respectifyComments` from `@respectify/astro/sqlite` (which reads Astro DB's text dates as UTC) and inserting through the Postgres table, keeping `id`, `parentId`, `approved` and `createdAt`. Insert in one transaction, parents before replies (order by `id`), and set any `parentId` whose parent no longer exists to null, since the Postgres table has a foreign key.
388
+ 3. Explicit ids leave the identity sequence at 1, so set it after the highest id copied: `select setval(pg_get_serial_sequence('respectify_comment', 'id'), <max id>, true)`.
389
+ 4. Read the rows back and compare them field by field before switching the site over.
390
+ 5. Point the runtime module at `createPostgresCommentStore(db)`, then remove `@astrojs/db` as above.
391
+
392
+ Run the copy as a dry run first, and have it check the target host and database before it writes.
393
+
284
394
  ## License
285
395
 
286
396
  MIT
@@ -3,6 +3,8 @@ export interface CommentResponse {
3
3
  author: string;
4
4
  content: string;
5
5
  createdAt: string;
6
+ /** The comment this one replies to, or null for a top-level comment */
7
+ parentId: number | null;
6
8
  }
7
9
 
8
10
  export function formatCommentDate(date: string | Date): string {
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+
3
+ /** Generates the reference Postgres migration in migrations/postgres from the adapter's table. */
4
+ export default defineConfig({
5
+ dialect: 'postgresql',
6
+ schema: './src/adapters/postgres/table.ts',
7
+ out: './migrations/postgres',
8
+ });
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+
3
+ /** Generates the reference SQLite migration in migrations/sqlite from the adapter's table. */
4
+ export default defineConfig({
5
+ dialect: 'sqlite',
6
+ schema: './src/adapters/sqlite/table.ts',
7
+ out: './migrations/sqlite',
8
+ });
@@ -0,0 +1,14 @@
1
+ CREATE TABLE "respectify_comment" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "respectify_comment_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "post_slug" text NOT NULL,
4
+ "author" text NOT NULL,
5
+ "email" text,
6
+ "content" text NOT NULL,
7
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
8
+ "approved" boolean DEFAULT false NOT NULL,
9
+ "parent_id" integer
10
+ );
11
+ --> statement-breakpoint
12
+ ALTER TABLE "respectify_comment" ADD CONSTRAINT "respectify_comment_parent_id_respectify_comment_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."respectify_comment"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
13
+ CREATE INDEX "respectify_comment_post_slug_created_at_idx" ON "respectify_comment" USING btree ("post_slug","created_at");--> statement-breakpoint
14
+ CREATE INDEX "respectify_comment_parent_id_idx" ON "respectify_comment" USING btree ("parent_id");
@@ -0,0 +1,144 @@
1
+ {
2
+ "id": "79148351-cfed-4a49-abf8-72f584610262",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.respectify_comment": {
8
+ "name": "respectify_comment",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "integer",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "identity": {
17
+ "type": "byDefault",
18
+ "name": "respectify_comment_id_seq",
19
+ "schema": "public",
20
+ "increment": "1",
21
+ "startWith": "1",
22
+ "minValue": "1",
23
+ "maxValue": "2147483647",
24
+ "cache": "1",
25
+ "cycle": false
26
+ }
27
+ },
28
+ "post_slug": {
29
+ "name": "post_slug",
30
+ "type": "text",
31
+ "primaryKey": false,
32
+ "notNull": true
33
+ },
34
+ "author": {
35
+ "name": "author",
36
+ "type": "text",
37
+ "primaryKey": false,
38
+ "notNull": true
39
+ },
40
+ "email": {
41
+ "name": "email",
42
+ "type": "text",
43
+ "primaryKey": false,
44
+ "notNull": false
45
+ },
46
+ "content": {
47
+ "name": "content",
48
+ "type": "text",
49
+ "primaryKey": false,
50
+ "notNull": true
51
+ },
52
+ "created_at": {
53
+ "name": "created_at",
54
+ "type": "timestamp with time zone",
55
+ "primaryKey": false,
56
+ "notNull": true,
57
+ "default": "now()"
58
+ },
59
+ "approved": {
60
+ "name": "approved",
61
+ "type": "boolean",
62
+ "primaryKey": false,
63
+ "notNull": true,
64
+ "default": false
65
+ },
66
+ "parent_id": {
67
+ "name": "parent_id",
68
+ "type": "integer",
69
+ "primaryKey": false,
70
+ "notNull": false
71
+ }
72
+ },
73
+ "indexes": {
74
+ "respectify_comment_post_slug_created_at_idx": {
75
+ "name": "respectify_comment_post_slug_created_at_idx",
76
+ "columns": [
77
+ {
78
+ "expression": "post_slug",
79
+ "isExpression": false,
80
+ "asc": true,
81
+ "nulls": "last"
82
+ },
83
+ {
84
+ "expression": "created_at",
85
+ "isExpression": false,
86
+ "asc": true,
87
+ "nulls": "last"
88
+ }
89
+ ],
90
+ "isUnique": false,
91
+ "concurrently": false,
92
+ "method": "btree",
93
+ "with": {}
94
+ },
95
+ "respectify_comment_parent_id_idx": {
96
+ "name": "respectify_comment_parent_id_idx",
97
+ "columns": [
98
+ {
99
+ "expression": "parent_id",
100
+ "isExpression": false,
101
+ "asc": true,
102
+ "nulls": "last"
103
+ }
104
+ ],
105
+ "isUnique": false,
106
+ "concurrently": false,
107
+ "method": "btree",
108
+ "with": {}
109
+ }
110
+ },
111
+ "foreignKeys": {
112
+ "respectify_comment_parent_id_respectify_comment_id_fk": {
113
+ "name": "respectify_comment_parent_id_respectify_comment_id_fk",
114
+ "tableFrom": "respectify_comment",
115
+ "tableTo": "respectify_comment",
116
+ "columnsFrom": [
117
+ "parent_id"
118
+ ],
119
+ "columnsTo": [
120
+ "id"
121
+ ],
122
+ "onDelete": "set null",
123
+ "onUpdate": "no action"
124
+ }
125
+ },
126
+ "compositePrimaryKeys": {},
127
+ "uniqueConstraints": {},
128
+ "policies": {},
129
+ "checkConstraints": {},
130
+ "isRLSEnabled": false
131
+ }
132
+ },
133
+ "enums": {},
134
+ "schemas": {},
135
+ "sequences": {},
136
+ "roles": {},
137
+ "policies": {},
138
+ "views": {},
139
+ "_meta": {
140
+ "columns": {},
141
+ "schemas": {},
142
+ "tables": {}
143
+ }
144
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1792852599748,
9
+ "tag": "0000_respectify_comment",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,13 @@
1
+ CREATE TABLE `Comment` (
2
+ `id` integer PRIMARY KEY NOT NULL,
3
+ `postSlug` text NOT NULL,
4
+ `author` text NOT NULL,
5
+ `email` text,
6
+ `content` text NOT NULL,
7
+ `createdAt` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
8
+ `approved` integer DEFAULT false NOT NULL,
9
+ `parentId` integer
10
+ );
11
+ --> statement-breakpoint
12
+ CREATE INDEX `Comment_postSlug_idx` ON `Comment` (`postSlug`);--> statement-breakpoint
13
+ CREATE INDEX `Comment_approved_idx` ON `Comment` (`approved`);
@@ -0,0 +1,101 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "9e37e666-2c7c-46b3-b761-c0ae5cc112e3",
5
+ "prevId": "00000000-0000-0000-0000-000000000000",
6
+ "tables": {
7
+ "Comment": {
8
+ "name": "Comment",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "integer",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "postSlug": {
18
+ "name": "postSlug",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "author": {
25
+ "name": "author",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "email": {
32
+ "name": "email",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": false,
36
+ "autoincrement": false
37
+ },
38
+ "content": {
39
+ "name": "content",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": true,
43
+ "autoincrement": false
44
+ },
45
+ "createdAt": {
46
+ "name": "createdAt",
47
+ "type": "text",
48
+ "primaryKey": false,
49
+ "notNull": true,
50
+ "autoincrement": false,
51
+ "default": "CURRENT_TIMESTAMP"
52
+ },
53
+ "approved": {
54
+ "name": "approved",
55
+ "type": "integer",
56
+ "primaryKey": false,
57
+ "notNull": true,
58
+ "autoincrement": false,
59
+ "default": false
60
+ },
61
+ "parentId": {
62
+ "name": "parentId",
63
+ "type": "integer",
64
+ "primaryKey": false,
65
+ "notNull": false,
66
+ "autoincrement": false
67
+ }
68
+ },
69
+ "indexes": {
70
+ "Comment_postSlug_idx": {
71
+ "name": "Comment_postSlug_idx",
72
+ "columns": [
73
+ "postSlug"
74
+ ],
75
+ "isUnique": false
76
+ },
77
+ "Comment_approved_idx": {
78
+ "name": "Comment_approved_idx",
79
+ "columns": [
80
+ "approved"
81
+ ],
82
+ "isUnique": false
83
+ }
84
+ },
85
+ "foreignKeys": {},
86
+ "compositePrimaryKeys": {},
87
+ "uniqueConstraints": {},
88
+ "checkConstraints": {}
89
+ }
90
+ },
91
+ "views": {},
92
+ "enums": {},
93
+ "_meta": {
94
+ "schemas": {},
95
+ "tables": {},
96
+ "columns": {}
97
+ },
98
+ "internal": {
99
+ "indexes": {}
100
+ }
101
+ }