-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): Change dedupe value column type from varchar(255) to text (#…
- Loading branch information
1 parent
0ac1b18
commit 6b272b0
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...cli/src/databases/migrations/common/1729607673464-UpdateProcessedDataValueColumnToText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { MigrationContext, ReversibleMigration } from '@/databases/types'; | ||
|
||
const processedDataTableName = 'processed_data'; | ||
export class UpdateProcessedDataValueColumnToText1729607673464 implements ReversibleMigration { | ||
async up({ schemaBuilder: { addNotNull }, isMysql, runQuery, tablePrefix }: MigrationContext) { | ||
const prefixedTableName = `${tablePrefix}${processedDataTableName}`; | ||
await runQuery(`ALTER TABLE ${prefixedTableName} ADD COLUMN value_temp TEXT;`); | ||
await runQuery(`UPDATE ${prefixedTableName} SET value_temp = value;`); | ||
await runQuery(`ALTER TABLE ${prefixedTableName} DROP COLUMN value;`); | ||
|
||
if (isMysql) { | ||
await runQuery(`ALTER TABLE ${prefixedTableName} CHANGE value_temp value TEXT NOT NULL;`); | ||
} else { | ||
await runQuery(`ALTER TABLE ${prefixedTableName} RENAME COLUMN value_temp TO value`); | ||
await addNotNull(processedDataTableName, 'value'); | ||
} | ||
} | ||
|
||
async down({ schemaBuilder: { addNotNull }, isMysql, runQuery, tablePrefix }: MigrationContext) { | ||
const prefixedTableName = `${tablePrefix}${processedDataTableName}`; | ||
await runQuery(`ALTER TABLE ${prefixedTableName} ADD COLUMN value_temp VARCHAR(255);`); | ||
await runQuery(`UPDATE ${prefixedTableName} SET value_temp = value;`); | ||
await runQuery(`ALTER TABLE ${prefixedTableName} DROP COLUMN value;`); | ||
|
||
if (isMysql) { | ||
await runQuery( | ||
`ALTER TABLE ${prefixedTableName} CHANGE value_temp value VARCHAR(255) NOT NULL;`, | ||
); | ||
} else { | ||
await runQuery(`ALTER TABLE ${prefixedTableName} RENAME COLUMN value_temp TO value`); | ||
await addNotNull(processedDataTableName, 'value'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters