Skip to content

feat: migration 0015 — channel protection settings (protect_lgbtqia, protect_women) - #78

Merged
Bonobo791 merged 2 commits into
mainfrom
mt-protect-flags
Aug 5, 2026
Merged

feat: migration 0015 — channel protection settings (protect_lgbtqia, protect_women)#78
Bonobo791 merged 2 commits into
mainfrom
mt-protect-flags

Conversation

@Bonobo791

@Bonobo791 Bonobo791 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

User description

What

Per-channel protection settings, database lane only (the settings UI and scoring behavior belong to the backend/frontend agents). Expand-only per I7:

  • drizzle/0015_channels_protect_flags.sql: channels gains protect_lgbtqia and protect_women, both integer NOT NULL DEFAULT 0 — the marketing_opt_in convention for off-by-default toggles. The DEFAULT fills existing rows in place; no backfill statement needed.
  • schema.ts: both columns after toneLevel (settings grouping), with semantics comments.
  • src/lib/server/db/migration-0015.test.ts: behavior tests in the 0013/0014 pattern (failing first, then green).
  • src/lib/server/testdb.ts: fixture gains both columns.

Behavior tests

  • both columns exist (17 total), NOT NULL with DEFAULT 0; pre-existing rows read 0 with no backfill
  • new inserts default to 0; explicit opt-in (1) is writable
  • tenancy contract channels_org_requires_owner still bites

Verification

  • npx vitest run src/lib/server/db/migration-0015.test.ts: 3/3 (watched ENOENT red → green)
  • npm run check 0/0, npm run test 51 files / 430 tests green, npm run build clean, codacy-analysis 0 issues on all changed files
  • Dev DB application: PENDING — see below. npm run db:migrate exited 0, but the dev Turso upstream went 502 (connect to upstream failed, also via turso db shell dev) immediately afterwards, so the post-application verification (0007-incident rule: verify the schema, not the exit code) has not run yet. I will verify (16 migrations, both columns present, existing rows read 0) and confirm in a comment as soon as the dev DB recovers. If the earlier run proves hollow, npm run db:migrate will simply be re-run.

Prod application: human per DEPLOY.md §1 after merge, then scripts/verify-tenancy.mjs must end ALL CHECKS PASSED.


CodeAnt-AI Description

Add per-channel protection settings for LGBTQIA+ people and women

What Changed

  • Channels now store separate protection settings for comments targeting LGBTQIA+ people and women
  • Both settings default to off for existing and newly created channels, while explicit opt-in values are supported
  • Existing channel data and ownership rules remain intact during the migration
  • Migration tests now cover defaults, opt-in values, data preservation, and shared test cleanup

Impact

✅ Per-channel protection controls
✅ Safe defaults for existing channels
✅ Preserved channel ownership rules

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@cla-bot cla-bot Bot added the cla-signed label Aug 4, 2026
@codeant-ai

codeant-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed 85b3695 Aug 04, 2026 · 22:33 22:36
✅ Reviewed your PR f9e1f00 Aug 04, 2026 · 21:55 21:57

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for moderaty ready!

Name Link
🔨 Latest commit 85b3695
🔍 Latest deploy log https://app.netlify.com/projects/moderaty/deploys/6a7268cd4a4a3f00082da943
😎 Deploy Preview https://deploy-preview-78--moderaty.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 90
Accessibility: 97
Best Practices: 100
SEO: 100
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Aug 4, 2026
@codeant-ai

codeant-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Sequence Diagram

This PR adds two per-channel protection flags to the database schema. Existing and new channels default to disabled, while explicit protection settings can be stored without changing the existing tenancy constraint.

sequenceDiagram
    participant Migration Runner
    participant Database
    participant Application

    Migration Runner->>Database: Apply channel settings migration
    Database->>Database: Add two protection flags with default disabled
    Database-->>Migration Runner: Existing channels read as disabled
    Application->>Database: Create channel without protection settings
    Database-->>Application: Store both flags as disabled
    Application->>Database: Create channel with protection enabled
    Database-->>Application: Store explicit protection settings
Loading

Generated by CodeAnt AI

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration adds per-channel protection settings (protect_lgbtqia and protect_women) with proper backward compatibility. The implementation is solid with expand-only schema changes, appropriate defaults (0 for off-by-default), and comprehensive test coverage.

All critical aspects are correctly implemented:

  • SQL migration uses NOT NULL DEFAULT 0 to fill existing rows without backfill
  • Schema definitions match the migration structure
  • Test fixtures updated to include new columns
  • Migration tests verify column existence, constraints, defaults, and tenancy contract preservation

The changes follow established patterns and maintain database integrity. Ready for merge once dev DB verification is confirmed (as noted in the PR description).


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@codacy-production

codacy-production Bot commented Aug 4, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 7 complexity · -1 duplication

Metric Results
Complexity 7 (≤ 100 complexity)
Duplication -1 (≤ 1 duplication)

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codeant-ai

codeant-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

🏁 CodeAnt Quality Gate Results

Commit: 85b36957
Scan Time: 2026-08-04 22:36:14 UTC

✅ Overall Status: PASSED

Quality Gate Details

Quality Gate Status Details
Secrets ✅ PASSED 0 secrets found
Duplicate Code ✅ PASSED 0.0% duplicated
SAST ✅ PASSED No security issues
Bugs ✅ PASSED Rating S: No bugs
IAC ✅ PASSED Rating S: No issues

View Full Results

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Migration 0015: add per-channel protect_lgbtqia/protect_women flags

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add per-channel protection flags to channels (off by default, expand-only).
• Update Drizzle schema artifacts and test DB fixture to include new columns.
• Add migration behavior tests for defaults, opt-in writes, and tenancy constraint.
Diagram

graph TD
  T(["migration-0015.test.ts"]) --> M["0015_channels_protect_flags.sql"] --> C[("channels table")]
  C --> S["schema.ts"]
  D["drizzle/meta snapshot+journal"] --> C
  F["testdb.ts fixture"] --> C

  subgraph Legend
    direction LR
    _test(["Test"]) ~~~ _file["Migration/Code"] ~~~ _db[("Database")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Store protection settings as JSON blob
  • ➕ Avoids adding new columns for each future protection toggle
  • ➕ Can evolve without migrations for small additions
  • ➖ Harder to query/index and enforce NOT NULL/DEFAULT semantics
  • ➖ More application-side parsing/validation; weaker schema clarity
2. Normalize into a channel_settings table
  • ➕ Keeps channels narrower as settings grow
  • ➕ Clear boundary for settings ownership and future expansion
  • ➖ Extra join everywhere settings are needed
  • ➖ More migration and data-access complexity for just two flags
3. Use a single bitmask integer column
  • ➕ One column scales to many boolean flags
  • ➕ Compact representation
  • ➖ Less self-documenting; more error-prone when adding/removing flags
  • ➖ Harder to query individual flags cleanly across SQL/ORM

Recommendation: The PR’s approach (explicit NOT NULL DEFAULT 0 integer columns) is the best fit given the expand-only requirement and the existing marketing_opt_in convention. It keeps querying and ORM typing straightforward, preserves existing-row behavior without backfill, and is easy to validate via the added behavior tests. The alternatives mainly pay off only if a large number of similar toggles is expected soon.

Files changed (6) +1062 / -0

Enhancement (2) +25 / -0
0015_channels_protect_flags.sqlAdd two per-channel protection flag columns +23/-0

Add two per-channel protection flag columns

• Introduces migration 0015 that adds 'protect_lgbtqia' and 'protect_women' to 'channels'. Both are 'integer NOT NULL DEFAULT 0' to remain off by default and to fill existing rows without backfill.

drizzle/0015_channels_protect_flags.sql

schema.tsExpose protect_lgbtqia/protect_women in Drizzle channels schema +2/-0

Expose protect_lgbtqia/protect_women in Drizzle channels schema

• Adds 'protectLgbtqia' and 'protectWomen' columns to the 'channels' table definition. Both are required with default 0 and include comments describing semantics for downstream wiring.

src/lib/server/db/schema.ts

Tests (2) +115 / -0
migration-0015.test.tsAdd behavior tests for migration 0015 defaults and constraints +113/-0

Add behavior tests for migration 0015 defaults and constraints

• Creates an in-memory pre-0015 'channels' table, applies the migration statements, and asserts both new columns exist with 'NOT NULL DEFAULT 0'. Verifies existing rows read as 0, new inserts default to 0, explicit opt-in values are writable, and the 'channels_org_requires_owner' check constraint still enforces tenancy rules.

src/lib/server/db/migration-0015.test.ts

testdb.tsUpdate test DB channels fixture DDL with new protection flags +2/-0

Update test DB channels fixture DDL with new protection flags

• Extends the 'channels' fixture table definition to include 'protect_lgbtqia' and 'protect_women' as 'NOT NULL DEFAULT 0'. Keeps the test schema aligned with migration 0015 expectations.

src/lib/server/testdb.ts

Other (2) +922 / -0
0015_snapshot.jsonRegenerate Drizzle schema snapshot for migration 0015 +915/-0

Regenerate Drizzle schema snapshot for migration 0015

• Adds the Drizzle snapshot capturing the updated 'channels' table shape. Reflects the two new columns with NOT NULL and default values.

drizzle/meta/0015_snapshot.json

_journal.jsonRegister migration 0015 in Drizzle journal +7/-0

Register migration 0015 in Drizzle journal

• Appends a new journal entry for '0015_channels_protect_flags' so Drizzle tracks the migration in order. Marks it with breakpoints enabled per existing convention.

drizzle/meta/_journal.json

Repository owner deleted a comment from coderabbitai Bot Aug 4, 2026
@qodo-code-review

qodo-code-review Bot commented Aug 4, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (3) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Unguarded reads via channels schema 📘 Rule violation ≡ Correctness
Description
New channels columns were added to the Drizzle schema, but some runtime code selects all
channels columns (no projection), which can fail with no such column if the migration hasn't
been applied yet. This violates the requirement to guard reads of newly added columns or guarantee
migrations run before serving traffic.
Code

src/lib/server/db/schema.ts[R103-106]

	toneLevel: integer('tone_level'), // moderation sensitivity: null or 1 = omni only, 2 = omni + tone pass
+	protectLgbtqia: integer('protect_lgbtqia').notNull().default(0), // protection setting: 1 = heightened protection for comments targeting LGBTQIA+ people
+	protectWomen: integer('protect_women').notNull().default(0), // protection setting: 1 = heightened protection for comments targeting women
	createdAt: text('created_at').notNull().default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`)
Relevance

●●● Strong

Team previously accepted preventing missing-column runtime failures by aligning reads with
migrations/new columns.

PR-#3

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2407776 requires guarding reads of newly added DB columns unless migrations are
guaranteed to run before application code executes. This PR adds new channels columns in the
schema and migration, while runtime code performs db.select().from(channels)... (implicit "select
all columns"), and the DB module does not run migrations automatically—so the read path can fail if
migrations lag behind code deployment.

Rule 2407776: Guard reads of newly added database columns until after migrations are applied
src/lib/server/db/schema.ts[101-106]
drizzle/0015_channels_protect_flags.sql[19-23]
src/lib/server/pipeline.ts[523-526]
src/lib/server/db/index.ts[30-48]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Adding new columns to the Drizzle `channels` schema can break existing `select().from(channels)` queries (which select all schema columns) when the database has not yet received the migration.

## Issue Context
There is no visible runtime guarantee that migrations are applied before handlers/jobs execute, so reads must be guarded or queries must avoid implicitly selecting newly-added columns.

## Fix Focus Areas
- src/lib/server/db/schema.ts[101-106]
- src/lib/server/pipeline.ts[515-533]
- src/lib/server/db/index.ts[30-48]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Spaces indentation in Drizzle JSON 📘 Rule violation ⚙ Maintainability
Description
The changed Drizzle meta JSON files use leading spaces for indentation instead of tabs. This
violates the repository indentation rule for changed source files.
Code

drizzle/meta/_journal.json[R110-115]

+    {
+      "idx": 15,
+      "version": "6",
+      "when": 1785879950529,
+      "tag": "0015_channels_protect_flags",
+      "breakpoints": true
Relevance

●●● Strong

Repo rule enforces tabs; fixing generated JSON indentation is low-risk, mechanical formatting
change.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2401137 requires indentation to be tabs (not spaces) in changed source files. The
updated _journal.json block and the newly added 0015_snapshot.json show leading spaces before
JSON keys.

Rule 2401137: Use tabs for indentation, never spaces
drizzle/meta/_journal.json[106-116]
drizzle/meta/0015_snapshot.json[1-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Changed Drizzle meta JSON uses space-indentation, violating the tabs-only indentation rule.

## Issue Context
These files are part of the committed source-of-truth for migrations, and the rule requires tabs for indentation in changed files.

## Fix Focus Areas
- drizzle/meta/_journal.json[106-116]
- drizzle/meta/0015_snapshot.json[1-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. Relative import in migration test 📘 Rule violation ⚙ Maintainability
Description
migration-0015.test.ts imports migrationTestUtils via a relative path even though the target
module is under src/lib, which violates the $lib-alias import requirement. This reduces
consistency and can make refactors/moves harder across the codebase.
Code

src/lib/server/db/migration-0015.test.ts[22]

+import { migrationStatements } from './migrationTestUtils';
Relevance

● Weak

Team has rejected switching test-file relative imports to $lib alias in similar cases.

PR-#50
PR-#35

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 2401155 requires $lib alias usage for any imports that resolve into src/lib.
The added import ./migrationTestUtils in migration-0015.test.ts resolves to a module under
src/lib/server/db/, so it violates the rule.

Rule 2401155: Use $lib alias instead of relative paths for src/lib imports
src/lib/server/db/migration-0015.test.ts[19-23]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A new file under `src/lib/...` imports another `src/lib/...` module using a relative path (`./migrationTestUtils`) instead of the required `$lib/...` alias.

## Issue Context
The compliance rule requires that any imports resolving into `src/lib` use the `$lib` alias for consistency.

## Fix Focus Areas
- src/lib/server/db/migration-0015.test.ts[19-23]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context used
✅ Compliance rules (platform): 78 rules

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment on lines 103 to 106
toneLevel: integer('tone_level'), // moderation sensitivity: null or 1 = omni only, 2 = omni + tone pass
protectLgbtqia: integer('protect_lgbtqia').notNull().default(0), // protection setting: 1 = heightened protection for comments targeting LGBTQIA+ people
protectWomen: integer('protect_women').notNull().default(0), // protection setting: 1 = heightened protection for comments targeting women
createdAt: text('created_at').notNull().default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Unguarded reads via channels schema 📘 Rule violation ≡ Correctness

New channels columns were added to the Drizzle schema, but some runtime code selects all
channels columns (no projection), which can fail with no such column if the migration hasn't
been applied yet. This violates the requirement to guard reads of newly added columns or guarantee
migrations run before serving traffic.
Agent Prompt
## Issue description
Adding new columns to the Drizzle `channels` schema can break existing `select().from(channels)` queries (which select all schema columns) when the database has not yet received the migration.

## Issue Context
There is no visible runtime guarantee that migrations are applied before handlers/jobs execute, so reads must be guarded or queries must avoid implicitly selecting newly-added columns.

## Fix Focus Areas
- src/lib/server/db/schema.ts[101-106]
- src/lib/server/pipeline.ts[515-533]
- src/lib/server/db/index.ts[30-48]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +110 to +115
{
"idx": 15,
"version": "6",
"when": 1785879950529,
"tag": "0015_channels_protect_flags",
"breakpoints": true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Spaces indentation in drizzle json 📘 Rule violation ⚙ Maintainability

The changed Drizzle meta JSON files use leading spaces for indentation instead of tabs. This
violates the repository indentation rule for changed source files.
Agent Prompt
## Issue description
Changed Drizzle meta JSON uses space-indentation, violating the tabs-only indentation rule.

## Issue Context
These files are part of the committed source-of-truth for migrations, and the rule requires tabs for indentation in changed files.

## Fix Focus Areas
- drizzle/meta/_journal.json[106-116]
- drizzle/meta/0015_snapshot.json[1-25]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

…lpers

Codacy flagged 2 new clones in migration-0015.test.ts (migratedDb +
afterEach client tracking, tenancy-contract insert) copied from the 0014
test. Extract applyMigration/closeMigratedDbs/expectTenancyContract into
migrationTestUtils and use them in all three migration tests, so the
scaffolding exists once. Assertions unchanged; 0013's migratedDb also
gains the client-close tracking it lacked.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Bonobo791, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9a8da0ca-70de-41d3-8579-9c86962aeed3

📥 Commits

Reviewing files that changed from the base of the PR and between 1f15866 and 85b3695.

📒 Files selected for processing (9)
  • drizzle/0015_channels_protect_flags.sql
  • drizzle/meta/0015_snapshot.json
  • drizzle/meta/_journal.json
  • src/lib/server/db/migration-0013.test.ts
  • src/lib/server/db/migration-0014.test.ts
  • src/lib/server/db/migration-0015.test.ts
  • src/lib/server/db/migrationTestUtils.ts
  • src/lib/server/db/schema.ts
  • src/lib/server/testdb.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added size:XXL This PR changes 1000+ lines, ignoring generated files and removed size:XXL This PR changes 1000+ lines, ignoring generated files labels Aug 4, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

@Bonobo791

Copy link
Copy Markdown
Owner Author

Review triage (round 1)

qodo-code-review — "Unguarded reads via channels schema" (schema.ts:106): valid as a systemic observation, not actionable in this migration PR. The full-row select().from(channels) pattern predates this change and is identical for every expand migration 0001–0014 (including merged 0014, same shape). Nullable columns would not help — the failure mode is the missing column name, not nullability. The repo's accepted mitigation is invariant I7 (migration applied and verified before code reading the new columns is exercised; prod migrations are human-applied per DEPLOY.md §1). Guarding all channel reads with projections or automating migrate-before-deploy is backend/deploy-process work — tracked in #81 so it isn't lost. No code change here; deviation from the suggestion is deliberate.

qodo-code-review — "Spaces indentation in drizzle json" (_journal.json:115): invalid, not fixing. drizzle/meta/_journal.json and *_snapshot.json are drizzle-kit–generated artifacts; every committed meta file (0000 through merged 0014) uses the generator's 2-space indentation, and these match. Hand-converting to tabs would diverge from the generator and be silently reverted on the next drizzle-kit generate. The tabs rule applies to hand-written source.

Codacy — "2 new code clones" in migration-0015.test.ts: valid, fixed in 85b3695. The cloned scaffolding (migratedDb + afterEach client tracking, tenancy-contract insert) is now shared helpers in migrationTestUtils.ts (applyMigration, closeMigratedDbs, expectTenancyContract), used by all three migration tests (0013/0014/0015). Assertions unchanged — 11/11 migration tests green, full suite 430/430, check/build clean. Mutation-checked: corrupting the 0015 migration (DEFAULT 0→1) still fails the suite; restored file is byte-identical.

amazon-q-developer: approving review, no findings — thanks.

Snyk failures (Code test limit reached, 1 test has failed) also appear on merged PRs #71/#74 — org quota, not this diff.

@Bonobo791

Copy link
Copy Markdown
Owner Author

Dev verification — COMPLETE (was pending the Turso 502 outage)

The earlier hollow exit-0 was confirmed: dev had 15 migrations after the first migrate (the 0007 pattern — drizzle-kit exited 0 during the upstream outage without applying). Re-ran npm run db:migrate after recovery and verified against the actual schema:

dev (db):

  • __drizzle_migrations: 16 (0000–0015)
  • channels: 17 columns; protect_lgbtqia / protect_women are notnull=1, dflt_value=0; history_next_page_token / history_boundary present and nullable
  • Existing rows read protect_lgbtqia=0, protect_women=0 (DEFAULT filled them, no backfill needed)
  • scripts/verify-tenancy.mjs: ALL CHECKS PASSED (integrity, FK check, tenancy contract rejects owned channel with NULL org, personal-org invariants)

prod (moderaty) — 0014 state confirmed as a side check:

  • __drizzle_migrations: 15 (0000–0014), 15 columns incl. both history columns
  • 0 mid-drain channels (next_page_token IS NOT NULL), so the 0014 backfill was correctly a no-op

Ready for human merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant