Skip to content

Commit

Permalink
🔨 make name on datasets mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Jan 29, 2024
1 parent d2e8041 commit 253ae3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions db/migration/1706317870929-DatasetsFieldNameMandatory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class DatasetsFieldNameMandatory1706317870929
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// The name field is nullable in the DB schema but null is never used in the values in the DB,
// so it's better to make it mandatory in the DB schema.
await queryRunner.query(
`ALTER TABLE datasets MODIFY COLUMN name VARCHAR(512) NOT NULL`
)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE datasets MODIFY COLUMN name VARCHAR(512)`
)
}
}
2 changes: 1 addition & 1 deletion packages/@ourworldindata/types/src/dbTypes/Datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface DbInsertDataset {
isPrivate?: number
metadataEditedAt: Date
metadataEditedByUserId: number
name?: string | null
name: string
namespace: string
nonRedistributable?: number
shortName?: string | null
Expand Down

0 comments on commit 253ae3b

Please sign in to comment.