// migrations/20240115_modify_generated_column.ts
import { Knex } from "knex";
export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable("users", (table) => {
// Generated Column 삭제
table.dropColumn("full_name");
});
await knex.schema.alterTable("users", (table) => {
// 새로운 정의로 재생성
table.specificType(
"full_name",
"TEXT GENERATED ALWAYS AS (first_name || ' ' || last_name) STORED",
);
});
}
export async function down(knex: Knex): Promise<void> {
await knex.schema.alterTable("users", (table) => {
table.dropColumn("full_name");
});
// 이전 정의로 복원
await knex.schema.alterTable("users", (table) => {
table.specificType("full_name", "TEXT GENERATED ALWAYS AS (first_name || last_name) STORED");
});
}