@respectify/astro 0.2.0 → 1.0.1

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,104 @@ 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/runtime';
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
+ Import `defineRespectifyRuntime` from `@respectify/astro/runtime`, not `@respectify/astro`: the main entry is the integration and imports Astro's config, which bundling adapters such as Vercel can't put in a server function.
89
+
90
+ 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`).
91
+
92
+ ### 4. Add the integration
40
93
 
41
94
  ```ts
42
95
  // astro.config.ts
43
- import { defineConfig } from 'astro/config';
44
- import db from '@astrojs/db';
96
+ import { defineConfig, envField } from 'astro/config';
45
97
  import respectify from '@respectify/astro';
46
98
 
47
99
  export default defineConfig({
48
100
  site: 'https://yoursite.com',
49
101
  output: 'server',
50
102
  adapter: vercel(), // or node, netlify, etc.
103
+ env: {
104
+ schema: {
105
+ DATABASE_URL: envField.string({ context: 'server', access: 'secret' }),
106
+ },
107
+ },
51
108
  integrations: [
52
- db(),
53
109
  respectify({
54
- // Optional: customize post URL for Respectify topic context
55
- getPostUrl: (slug, site) => `${site}/blog/${slug}/`,
110
+ runtime: './src/respectify.runtime.ts',
56
111
  }),
57
112
  ],
58
113
  });
59
114
  ```
60
115
 
61
- ### 3. Configure Respectify
116
+ ### 5. Configure Respectify
62
117
 
63
118
  Copy a starter config to your project root:
64
119
 
@@ -77,53 +132,10 @@ Add environment variables:
77
132
  ```env
78
133
  RESPECTIFY_EMAIL=you@example.com
79
134
  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 } });
109
- ```
110
-
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
135
+ DATABASE_URL=postgres://...
124
136
  ```
125
137
 
126
- ### 5. Wire up Astro Actions
138
+ ### 6. Wire up Astro Actions
127
139
 
128
140
  ```ts
129
141
  // src/actions/index.ts
@@ -134,7 +146,7 @@ export const server = {
134
146
  };
135
147
  ```
136
148
 
137
- ### 6. Add comments to your layout
149
+ ### 7. Add comments to your layout
138
150
 
139
151
  ```astro
140
152
  ---
@@ -146,6 +158,42 @@ import CommentSection from '@respectify/astro/components/CommentSection.astro';
146
158
 
147
159
  That's it. Comments are moderated by Respectify before they appear.
148
160
 
161
+ ## Storage
162
+
163
+ The actions, the comments API route and the moderation service depend only on the `ICommentStore` interface:
164
+
165
+ ```ts
166
+ interface ICommentStore {
167
+ findById(id: number): Promise<CommentRecord | undefined>;
168
+ listApproved(postSlug: string): Promise<PublicComment[]>; // oldest first, ties by id
169
+ create(input: NewComment): Promise<CommentRecord>; // validates with newCommentSchema
170
+ delete(id: number): Promise<boolean>; // replies are kept, with parentId null
171
+ }
172
+ ```
173
+
174
+ | Store | Import | Works with |
175
+ | --- | --- | --- |
176
+ | `createPostgresCommentStore(db, { table? })` | `@respectify/astro/postgres` | Any Drizzle Postgres database: node-postgres, postgres.js, Neon, PGlite, … |
177
+ | `createSqliteCommentStore(db, { table? })` | `@respectify/astro/sqlite` | Any Drizzle SQLite database: libSQL/Turso, better-sqlite3, Cloudflare D1, … |
178
+
179
+ Both take your Drizzle database instance and never open a connection of their own.
180
+
181
+ ### Writing your own store
182
+
183
+ Implement `ICommentStore` (types from `@respectify/astro`) and run the shared contract suite, which every built-in store passes, against it with Vitest:
184
+
185
+ ```ts
186
+ // test/my-comment-store.test.ts
187
+ import { describeCommentStoreContract } from '@respectify/astro/testing';
188
+
189
+ describeCommentStoreContract('my store', async () => ({
190
+ store: createMyCommentStore(await createEmptyTestDatabase()),
191
+ dispose: () => closeTestDatabase(),
192
+ }));
193
+ ```
194
+
195
+ The factory must return a store on a new, empty table each time.
196
+
149
197
  ## Component props
150
198
 
151
199
  | Prop | Default | Description |
@@ -172,25 +220,23 @@ Override on `.rf-comments`:
172
220
 
173
221
  ### Integration options
174
222
 
175
- Any `@respectify/client` option can be set via `client` and `megacall`. Values in `astro.config` override the same keys in `respectify.config.json`.
223
+ `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
224
 
177
225
  ```ts
178
226
  respectify({
227
+ // Required: the module whose default export is defineRespectifyRuntime({ store, ... })
228
+ runtime: './src/respectify.runtime.ts',
229
+
179
230
  configPath: './respectify.config.json',
180
231
  commentsApiPath: '/api/respectify/comments',
181
232
  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
233
 
189
234
  // Per-IP submission limit, enforced in the `comments.submit` action.
190
235
  // In-memory per server process — not shared across multiple instances/regions.
191
236
  rateLimit: { windowMs: 300_000, maxRequests: 10 },
192
237
 
193
- // Forwarded to RespectifyClient (email/apiKey still default from env)
238
+ // Forwarded to RespectifyClient. Credentials are not accepted here, since these options are
239
+ // written into the server bundle: use RESPECTIFY_EMAIL / RESPECTIFY_API_KEY
194
240
  client: {
195
241
  baseUrl: 'https://app.respectify.ai',
196
242
  timeout: 30_000,
@@ -215,6 +261,20 @@ respectify({
215
261
  });
216
262
  ```
217
263
 
264
+ The runtime module takes the store and the two optional post functions:
265
+
266
+ ```ts
267
+ export default defineRespectifyRuntime({
268
+ store,
269
+ // The canonical URL for a post, used to initialize Respectify topics (default: `${site}/posts/${slug}/`)
270
+ getPostUrl: (slug, site) => `${site}/posts/${slug}/`,
271
+ // Alternative to getPostUrl: hand Respectify the post body directly instead of having it
272
+ // fetch getPostUrl. Useful for staged/preview/auth-gated content, or when the URL isn't
273
+ // live yet right after deploy. Takes priority over getPostUrl.
274
+ getPostContent: async (slug) => loadPostBody(slug),
275
+ });
276
+ ```
277
+
218
278
  `showBranding` and `commentsApiPath` set here become the defaults for `<CommentSection>` — you can still override either per-instance via props.
219
279
 
220
280
  ### Checking Respectify credentials
@@ -225,7 +285,7 @@ import { verifyRespectifyCredentials } from '@respectify/astro/credentials';
225
285
  const isConnected = await verifyRespectifyCredentials();
226
286
  ```
227
287
 
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.
288
+ 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
289
 
230
290
  ### `respectify.config.json`
231
291
 
@@ -275,12 +335,64 @@ Set `enableDelete` on `CommentSection` and implement auth so `context.locals.isA
275
335
  Visitor submits comment
276
336
  → Astro Action (comments.submit)
277
337
  → 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
338
+ → If approved: store.create() saves it through your ICommentStore
339
+ → Client refreshes comment list via GET /api/respectify/comments (store.listApproved())
280
340
  ```
281
341
 
282
342
  Post pages can stay `prerender = true`. Only the API route and actions need server runtime.
283
343
 
344
+ ## Migrating from 0.x (Astro DB)
345
+
346
+ 1.0 removes Astro DB, which Astro deprecated in 6.4 and removed in 7.0, so it is a breaking release. What changes:
347
+
348
+ | 0.x | 1.0 |
349
+ | --- | --- |
350
+ | `@astrojs/db` peer dependency, `db()` integration, `db/config.ts` | Your own Drizzle database, passed to a store in a runtime module |
351
+ | `@respectify/astro/schema` | `@respectify/astro/sqlite` or `@respectify/astro/postgres` (`respectifyComments`) |
352
+ | `getPostUrl` / `getPostContent` in `respectify({...})` | In `defineRespectifyRuntime({...})`; passing them to `respectify()` now fails at startup |
353
+ | `astro db push`, `astro build --remote` | drizzle-kit (or your own migrations); plain `astro build` |
354
+ | `ASTRO_DB_REMOTE_URL`, `ASTRO_DB_APP_TOKEN` | Your own variables, declared with `astro:env` |
355
+ | `client.email` / `client.apiKey` in `respectify({...})` | `RESPECTIFY_EMAIL` / `RESPECTIFY_API_KEY` (or `respectify.config.json`); in `astro.config` they now fail at startup |
356
+ | `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` |
357
+ | Comments API returns `id, author, content, createdAt` | Adds `parentId` |
358
+
359
+ 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.
360
+
361
+ ### Keep your Turso database (no data to move)
362
+
363
+ 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.
364
+
365
+ 1. `npm uninstall @astrojs/db` and `npm install drizzle-orm @libsql/client`.
366
+ 2. Remove `db()` from `astro.config` and delete `db/config.ts`. Drop `--remote` from your build script.
367
+ 3. Declare the Turso URL and token in `astro.config`'s `env.schema` (they can keep their names), and write the runtime module:
368
+
369
+ ```ts
370
+ // src/respectify.runtime.ts
371
+ import { defineRespectifyRuntime } from '@respectify/astro/runtime';
372
+ import { createSqliteCommentStore } from '@respectify/astro/sqlite';
373
+ import { createClient } from '@libsql/client';
374
+ import { drizzle } from 'drizzle-orm/libsql';
375
+ import { ASTRO_DB_REMOTE_URL, ASTRO_DB_APP_TOKEN } from 'astro:env/server';
376
+
377
+ const db = drizzle({ client: createClient({ url: ASTRO_DB_REMOTE_URL, authToken: ASTRO_DB_APP_TOKEN }) });
378
+
379
+ export default defineRespectifyRuntime({ store: createSqliteCommentStore(db) });
380
+ ```
381
+
382
+ 4. Change `respectify({ ... })` to `respectify({ runtime: './src/respectify.runtime.ts', ... })`, moving any `getPostUrl` / `getPostContent` into the runtime module.
383
+
384
+ 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.
385
+
386
+ ### Move your comments to Postgres
387
+
388
+ 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)).
389
+ 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.
390
+ 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)`.
391
+ 4. Read the rows back and compare them field by field before switching the site over.
392
+ 5. Point the runtime module at `createPostgresCommentStore(db)`, then remove `@astrojs/db` as above.
393
+
394
+ Run the copy as a dry run first, and have it check the target host and database before it writes.
395
+
284
396
  ## License
285
397
 
286
398
  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
+ }