-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update project model adding is_template, video and template_sta…
…tus cols
- Loading branch information
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
migrations/1686943144806_update-projects-with-template-fields.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,24 @@ | ||
import { MigrationBuilder } from 'node-pg-migrate' | ||
import { Project } from '../src/Project' | ||
|
||
const tableName = Project.tableName | ||
|
||
/** | ||
* Migrates the DB by adding the is_template, video and template_status columns to the projects table. | ||
* The is_template column will be false for projects created by the users. | ||
* The video column will be null for projects created by the users or string for projects created as templates. | ||
* The template_status column will be null for projects created by the users or string for projects created as templates. | ||
*/ | ||
export async function up(pgm: MigrationBuilder): Promise<void> { | ||
pgm.addColumn(tableName, { | ||
['is_template']: { type: 'BOOLEAN', default: false, notNull: true }, | ||
['video']: { type: 'TEXT', default: null, notNull: false }, | ||
['template_status']: { type: 'TEXT', default: null, notNull: false }, | ||
}) | ||
} | ||
|
||
export async function down(pgm: MigrationBuilder): Promise<void> { | ||
pgm.dropColumn(tableName, 'is_template') | ||
pgm.dropColumn(tableName, 'video') | ||
pgm.dropColumn(tableName, 'template_status') | ||
} |
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