mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 11:38:55 +00:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { Knex } from "knex";
|
|
|
|
import { ProjectVersion, TableName } from "../schemas";
|
|
|
|
export async function up(knex: Knex): Promise<void> {
|
|
const hasGhostUserColumn = await knex.schema.hasColumn(TableName.Users, "isGhost");
|
|
const hasProjectVersionColumn = await knex.schema.hasColumn(TableName.Project, "version");
|
|
|
|
if (!hasGhostUserColumn) {
|
|
await knex.schema.alterTable(TableName.Users, (t) => {
|
|
t.boolean("isGhost").defaultTo(false).notNullable();
|
|
});
|
|
}
|
|
|
|
if (!hasProjectVersionColumn) {
|
|
await knex.schema.alterTable(TableName.Project, (t) => {
|
|
t.integer("version").defaultTo(ProjectVersion.V1).notNullable();
|
|
t.string("upgradeStatus").nullable();
|
|
});
|
|
}
|
|
}
|
|
|
|
export async function down(knex: Knex): Promise<void> {
|
|
const hasGhostUserColumn = await knex.schema.hasColumn(TableName.Users, "isGhost");
|
|
const hasProjectVersionColumn = await knex.schema.hasColumn(TableName.Project, "version");
|
|
|
|
if (hasGhostUserColumn) {
|
|
await knex.schema.alterTable(TableName.Users, (t) => {
|
|
t.dropColumn("isGhost");
|
|
});
|
|
}
|
|
|
|
if (hasProjectVersionColumn) {
|
|
await knex.schema.alterTable(TableName.Project, (t) => {
|
|
t.dropColumn("version");
|
|
t.dropColumn("upgradeStatus");
|
|
});
|
|
}
|
|
}
|