ReviewOS

also looking at this

loghqorg/loghq

Promote main to production: signed-out chrome and the subscriber tables

#17
Merged glennmichael123 wants to merge main into production
54 files +4252 -1353

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

database/migrations/0000000004-create-users-table.sqlmodified+13-1
Changes to database/migrations/0000000004-create-users-table.sql
@@ -3,8 +3,20 @@
33-- one (stacksjs/stacks#2346: it either keeps the postgres files or writes 80
44-- migrations for 78 framework models). Fixed upstream, unreleased. Regenerate
55-- and delete this note once it ships.
6--
7-- AUTOINCREMENT dropped, nothing else touched. This app now runs postgres, and
8-- `buddy migrate` refuses the ENTIRE corpus when any file is sqlite-only -- so
9-- that one keyword left loghq unable to apply any new migration at all. Bare
10-- `INTEGER PRIMARY KEY` parses in both dialects and is still a rowid alias in
11-- sqlite, so it still auto-assigns; the only thing given up is AUTOINCREMENT's
12-- guarantee never to reuse a deleted id.
13--
14-- Nothing here is rewritten into postgres DDL, because these files did not
15-- build the live postgres schema: users.id there is backed by users_id_seq, a
16-- sequence this DDL never creates, and 80 migrations are recorded as applied
17-- against 20 files on disk.
618CREATE TABLE IF NOT EXISTS "users" (
7 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
19 "id" INTEGER PRIMARY KEY,
820 "name" varchar(100) not null,
921 "email" varchar(255) not null,
1022 "password" varchar(255) not null,
database/migrations/0000000005-create-subscriptions-table.sqlmodified+6-1
Changes to database/migrations/0000000005-create-subscriptions-table.sql
@@ -3,8 +3,13 @@
33-- one (stacksjs/stacks#2346: it either keeps the postgres files or writes 80
44-- migrations for 78 framework models). Fixed upstream, unreleased. Regenerate
55-- and delete this note once it ships.
6--
7-- AUTOINCREMENT dropped, nothing else touched; see the fuller note in
8-- 0000000004-create-users-table.sql. In short: one sqlite-only keyword makes
9-- `buddy migrate` refuse the entire corpus, and bare `INTEGER PRIMARY KEY`
10-- parses in both dialects while still auto-assigning in sqlite.
611CREATE TABLE IF NOT EXISTS "subscriptions" (
7 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
12 "id" INTEGER PRIMARY KEY,
813 "type" text not null,
914 "plan" varchar(100),
1015 "provider_id" varchar(255) not null,
database/migrations/0000000008-create-email_suppressions-table.sqlmodified+6-1
Changes to database/migrations/0000000008-create-email_suppressions-table.sql
@@ -7,8 +7,13 @@
77-- (bounces, complaints, unsubscribes, manual blocks). The mail layer fails
88-- open when the table is missing on sqlite/mysql but not on postgres (its
99-- missing-table matcher doesn't know postgres phrasing), so ship the table.
10--
11-- AUTOINCREMENT dropped, nothing else touched; see the fuller note in
12-- 0000000004-create-users-table.sql. In short: one sqlite-only keyword makes
13-- `buddy migrate` refuse the entire corpus, and bare `INTEGER PRIMARY KEY`
14-- parses in both dialects while still auto-assigning in sqlite.
1015CREATE TABLE IF NOT EXISTS "email_suppressions" (
11 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
16 "id" INTEGER PRIMARY KEY,
1217 "email" varchar(255) NOT NULL,
1318 "type" varchar(32) NOT NULL,
1419 "reason" varchar(255),
database/migrations/0000000009-alter-password_resets-add-expires_at.sqlmodified+6-1
Changes to database/migrations/0000000009-alter-password_resets-add-expires_at.sql
@@ -12,8 +12,13 @@
1212-- skips it and the ALTER below would hard-fail. Mirror the framework schema
1313-- (storage/framework/core/database/src/auth-tables.ts) so this migration stands
1414-- alone, and is a no-op when the table already exists.
15--
16-- AUTOINCREMENT dropped, nothing else touched; see the fuller note in
17-- 0000000004-create-users-table.sql. In short: one sqlite-only keyword makes
18-- `buddy migrate` refuse the entire corpus, and bare `INTEGER PRIMARY KEY`
19-- parses in both dialects while still auto-assigning in sqlite.
1520CREATE TABLE IF NOT EXISTS "password_resets" (
16 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
21 "id" INTEGER PRIMARY KEY,
1722 "email" varchar(255) NOT NULL,
1823 "token" varchar(255) NOT NULL,
1924 "created_at" timestamp DEFAULT CURRENT_TIMESTAMP,
database/migrations/0000000017-auto-misc.sqlmodified+46-21
Changes to database/migrations/0000000017-auto-misc.sql
@@ -16,24 +16,49 @@
1616--
1717-- See stacksjs/stacks#2346 for the related migration-generator problems.
1818-- @generated by `buddy migrate:regenerate` — edits will be overwritten
19PRAGMA foreign_keys=OFF;
20BEGIN;
21CREATE TABLE "_qb_tmp_projects" (
22 "id" TEXT PRIMARY KEY,
23 "name" TEXT not null,
24 "platform" TEXT,
25 "dsn" TEXT,
26 "ingest_key" TEXT,
27 "owner_id" INTEGER,
28 "is_active" INTEGER,
29 "created_at" TEXT not null default CURRENT_TIMESTAMP,
30 "updated_at" TEXT
31);
32INSERT INTO "_qb_tmp_projects" ("id", "name", "platform", "dsn", "ingest_key", "owner_id", "is_active", "created_at", "updated_at") SELECT "id", "name", "platform", "dsn", "ingest_key", "owner_id", "is_active", "created_at", "updated_at" FROM "projects";
33DROP TABLE "projects";
34ALTER TABLE "_qb_tmp_projects" RENAME TO "projects";
35CREATE UNIQUE INDEX IF NOT EXISTS "projects_ingest_key_unique" ON "projects" ("ingest_key");
36CREATE UNIQUE INDEX IF NOT EXISTS "projects_projects_ingest_key_unique" ON "projects" ("ingest_key");
37PRAGMA foreign_key_check;
38COMMIT;
39PRAGMA foreign_keys=ON;
19--
20-- ---------------------------------------------------------------------------
21-- NEUTRALISED, NOT DELETED. The file and its original SQL are both kept below.
22--
23-- Everything above was written while this app ran sqlite, and the rebuild was
24-- always cosmetic: it existed only to clear a spurious `--diff`, and the note
25-- opens by saying it does nothing. loghq now runs postgres (DB_CONNECTION in
26-- .env), and this is the one migration of the twenty still unapplied here --
27-- `migrations` records 80 rows and none of them is this file.
28--
29-- So it was the only pending statement in the corpus, and on postgres it is
30-- not a no-op at all. `DROP TABLE "projects"` would meet four inbound foreign
31-- keys and be refused, failing the run; the sqlite table-rebuild idiom it uses
32-- (PRAGMA foreign_keys, a _qb_tmp_ copy, DROP, RENAME) has no meaning there.
33-- Its PRAGMA lines were also the last thing making `buddy migrate` reject the
34-- WHOLE corpus as sqlite-flavoured, which left this app unable to apply any
35-- new migration at all.
36--
37-- Replaced with a statement both dialects accept, so the file can be recorded
38-- as applied and stop blocking the rest. The original is directly below and in
39-- git history; restore it if loghq is ever pointed back at sqlite and the
40-- spurious diff returns.
41--
42-- PRAGMA foreign_keys=OFF;
43-- BEGIN;
44-- CREATE TABLE "_qb_tmp_projects" (
45-- "id" TEXT PRIMARY KEY,
46-- "name" TEXT not null,
47-- "platform" TEXT,
48-- "dsn" TEXT,
49-- "ingest_key" TEXT,
50-- "owner_id" INTEGER,
51-- "is_active" INTEGER,
52-- "created_at" TEXT not null default CURRENT_TIMESTAMP,
53-- "updated_at" TEXT
54-- );
55-- INSERT INTO "_qb_tmp_projects" ("id", "name", "platform", "dsn", "ingest_key", "owner_id", "is_active", "created_at", "updated_at") SELECT "id", "name", "platform", "dsn", "ingest_key", "owner_id", "is_active", "created_at", "updated_at" FROM "projects";
56-- DROP TABLE "projects";
57-- ALTER TABLE "_qb_tmp_projects" RENAME TO "projects";
58-- CREATE UNIQUE INDEX IF NOT EXISTS "projects_ingest_key_unique" ON "projects" ("ingest_key");
59-- CREATE UNIQUE INDEX IF NOT EXISTS "projects_projects_ingest_key_unique" ON "projects" ("ingest_key");
60-- PRAGMA foreign_key_check;
61-- COMMIT;
62-- PRAGMA foreign_keys=ON;
63-- ---------------------------------------------------------------------------
64SELECT 1;