Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(db): remove hard varchar length limits and stop migrations importing the umzug instance#222

Open
markcrivera wants to merge 3 commits into
mainmitre/tir:mainfrom
fix/varchar-to-text-12mitre/tir:fix/varchar-to-text-12Copy head branch name to clipboard
Open

fix(db): remove hard varchar length limits and stop migrations importing the umzug instance#222
markcrivera wants to merge 3 commits into
mainmitre/tir:mainfrom
fix/varchar-to-text-12mitre/tir:fix/varchar-to-text-12Copy head branch name to clipboard

Conversation

@markcrivera

Copy link
Copy Markdown
Collaborator

Summary

Removes every hard text-length limit from the database schema (#12), in the models, throughout the historical migration chain, and on existing deployments via a new idempotent normalizing migration. Converts all migrations to consume the Sequelize instance from umzug's context argument instead of importing it from db/umzug.js.

Changes

refactor(db): replace all varchar column types with TEXT

  • All DataTypes.STRING / STRING(n) / STRING(DATETIME_LENGTH) in migrations and models to DataTypes.TEXT
  • Raw-SQL VARCHAR(n) in the SQLite table rebuild blocks move to TEXT. Also fixes a parenless VARCHAR${DATETIME_LENGTH} typo that produced the type name VARCHAR29
  • DATETIME_LENGTH deleted from both definitions (db/umzug.js, server/utils/constants.ts) and from all migration import lists. Sample migration template updated

fix(db): add idempotent migration converting existing varchar columns to TEXT

  • Inspects information_schema for character varying columns, excluding SequelizeMeta and seeder_meta, and alters each to TEXT, rewriting column defaults carrying a ::character varying cast
  • Postgres-only: SQLite never enforced the lengths
  • No-op by construction on databases built from the rewritten chain

refactor(db): migrations consume the umzug context instead of importing the instance

  • All migrations: import { sequelize } from "../umzug.js" removed. up/down become async ({ context: sequelize })
  • In the packaged app this stops migration files loading a second copy of umzug.js from disk (second connection pool, duplicate hooks, runtime dotenv). The dev CLI (db/migrate.js / db/seed.js) is unaffected

Testing

  • Convergence: fresh database from the rewritten chain vs. a pre-change database after the normalizer. pg_dump --schema-only byte-identical, including the default-cast case (Users.creationMethod)
  • Upgrade safety: against an already-migrated database, migrate pending lists nothing after the normalizer.
  • Fresh install via dev CLI: node db/migrate.js up && node db/seed.js up applies 56 migrations + 13 seeders cleanly with context-injected migrations
  • Idempotency: re-running the normalizer converts nothing

Related

Closes #12

Rewrite every DataTypes.STRING / STRING(n) / STRING(DATETIME_LENGTH) in
migrations and models to DataTypes.TEXT, convert SQL VARCHAR(n) in the
SQLite table rebuild blocks, and fix a parenless VARCHAR${DATETIME_LENGTH}
typo that produced the type name VARCHAR29. Remove the unused
DATETIME_LENGTH constant from db/umzug.js and server/utils/constants.ts,
drop it from 39 migration import lists, and update the sample migration
template.

Refs #12

Signed-off-by: Mark Rivera <mcrivera@gmail.com>
… to TEXT

Postgres-only:
SQLite never enforced varchar lengths and its table rebuild path risks
constraint loss. On fresh databases built from the rewritten migration
chain the query matches nothing and the migration is a no-op.

Closes #12

Signed-off-by: Mark Rivera <mcrivera@gmail.com>
…ng the instance

Remove the runtime import of ../umzug.js from all 55 migrations and take
the Sequelize instance from the { context } argument the runner has always
passed like the seeders use.  Stops migration files from loading a second
copy of umzug.js from disk with its own connection pool, dotenv call, and
hooks. the dev CLI is unaffected.  Should clean up dotenv dev issues.

Signed-off-by: Mark Rivera <mcrivera@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
38.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@markcrivera
markcrivera requested a review from Amndeep7 July 25, 2026 18:36
@markcrivera

markcrivera commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator Author

Quality Gate Failed Quality Gate failed

Failed conditions 38.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Can't do anything about the duplicated code on database migrations. @Amndeep7, @aaronlippold can we get relief on this here?

@markcrivera
markcrivera requested a review from aaronlippold July 25, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove Hard Lengths from Database Schema

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.