also looking at this
Promote main to production: signed-out chrome and the subscriber tables
#17
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.
| @@ -3,8 +3,20 @@ | ||
| 3 | 3 | -- one (stacksjs/stacks#2346: it either keeps the postgres files or writes 80 |
| 4 | 4 | -- migrations for 78 framework models). Fixed upstream, unreleased. Regenerate |
| 5 | 5 | -- 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. | |
| 6 | 18 | CREATE TABLE IF NOT EXISTS "users" ( |
| 7 | "id" INTEGER PRIMARY KEY AUTOINCREMENT, | |
| 19 | "id" INTEGER PRIMARY KEY, | |
| 8 | 20 | "name" varchar(100) not null, |
| 9 | 21 | "email" varchar(255) not null, |
| 10 | 22 | "password" varchar(255) not null, |
| @@ -3,8 +3,13 @@ | ||
| 3 | 3 | -- one (stacksjs/stacks#2346: it either keeps the postgres files or writes 80 |
| 4 | 4 | -- migrations for 78 framework models). Fixed upstream, unreleased. Regenerate |
| 5 | 5 | -- 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. | |
| 6 | 11 | CREATE TABLE IF NOT EXISTS "subscriptions" ( |
| 7 | "id" INTEGER PRIMARY KEY AUTOINCREMENT, | |
| 12 | "id" INTEGER PRIMARY KEY, | |
| 8 | 13 | "type" text not null, |
| 9 | 14 | "plan" varchar(100), |
| 10 | 15 | "provider_id" varchar(255) not null, |
| @@ -7,8 +7,13 @@ | ||
| 7 | 7 | -- (bounces, complaints, unsubscribes, manual blocks). The mail layer fails |
| 8 | 8 | -- open when the table is missing on sqlite/mysql but not on postgres (its |
| 9 | 9 | -- 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. | |
| 10 | 15 | CREATE TABLE IF NOT EXISTS "email_suppressions" ( |
| 11 | "id" INTEGER PRIMARY KEY AUTOINCREMENT, | |
| 16 | "id" INTEGER PRIMARY KEY, | |
| 12 | 17 | "email" varchar(255) NOT NULL, |
| 13 | 18 | "type" varchar(32) NOT NULL, |
| 14 | 19 | "reason" varchar(255), |
| @@ -12,8 +12,13 @@ | ||
| 12 | 12 | -- skips it and the ALTER below would hard-fail. Mirror the framework schema |
| 13 | 13 | -- (storage/framework/core/database/src/auth-tables.ts) so this migration stands |
| 14 | 14 | -- 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. | |
| 15 | 20 | CREATE TABLE IF NOT EXISTS "password_resets" ( |
| 16 | "id" INTEGER PRIMARY KEY AUTOINCREMENT, | |
| 21 | "id" INTEGER PRIMARY KEY, | |
| 17 | 22 | "email" varchar(255) NOT NULL, |
| 18 | 23 | "token" varchar(255) NOT NULL, |
| 19 | 24 | "created_at" timestamp DEFAULT CURRENT_TIMESTAMP, |
| @@ -16,24 +16,49 @@ | ||
| 16 | 16 | -- |
| 17 | 17 | -- See stacksjs/stacks#2346 for the related migration-generator problems. |
| 18 | 18 | -- @generated by `buddy migrate:regenerate` — edits will be overwritten |
| 19 | PRAGMA foreign_keys=OFF; | |
| 20 | BEGIN; | |
| 21 | CREATE 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 | ); | |
| 32 | 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"; | |
| 33 | DROP TABLE "projects"; | |
| 34 | ALTER TABLE "_qb_tmp_projects" RENAME TO "projects"; | |
| 35 | CREATE UNIQUE INDEX IF NOT EXISTS "projects_ingest_key_unique" ON "projects" ("ingest_key"); | |
| 36 | CREATE UNIQUE INDEX IF NOT EXISTS "projects_projects_ingest_key_unique" ON "projects" ("ingest_key"); | |
| 37 | PRAGMA foreign_key_check; | |
| 38 | COMMIT; | |
| 39 | PRAGMA 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 | -- --------------------------------------------------------------------------- | |
| 64 | SELECT 1; | |