import { BaseSmartTags, PgColumn, PgTable, PgType } from '../../abstractions'; export class PkColumn implements PgColumn { name: string; readonly table: PgTable; readonly type: PgType; constructor(table: PgTable, type: PgType) { if (type !== 'INTEGER' && type !== 'TEXT') { throw new TypeError(`Type ${type} not supported as primary key.`); } this.name = 'id'; this.table = table; this.type = type; } buildSmartTags(): BaseSmartTags { return {}; } buildAdditionalStatements(): string[] { return []; } buildExpression(): string { let sql = `${this.name} ${this.type} PRIMARY KEY`; if (this.type === 'INTEGER') { sql = `${sql} GENERATED BY DEFAULT AS IDENTITY`; } return sql; } }