mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-21 21:47:17 +00:00
80 lines
2 KiB
TypeScript
80 lines
2 KiB
TypeScript
|
|
import { MigrationInterface, QueryRunner, Table, TableForeignKey, TableUnique } from 'typeorm';
|
||
|
|
|
||
|
|
export class CreateOrgEnvironmentVariablesTable1652541462886 implements MigrationInterface {
|
||
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||
|
|
await queryRunner.createTable(
|
||
|
|
new Table({
|
||
|
|
name: 'org_environment_variables',
|
||
|
|
columns: [
|
||
|
|
{
|
||
|
|
name: 'id',
|
||
|
|
type: 'uuid',
|
||
|
|
isGenerated: true,
|
||
|
|
default: 'gen_random_uuid()',
|
||
|
|
isPrimary: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'organization_id',
|
||
|
|
type: 'uuid',
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'variable_name',
|
||
|
|
type: 'varchar',
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'value',
|
||
|
|
type: 'varchar',
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'variable_type',
|
||
|
|
type: 'enum',
|
||
|
|
enumName: 'variable_type',
|
||
|
|
enum: ['client', 'server'],
|
||
|
|
isNullable: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'encrypted',
|
||
|
|
type: 'boolean',
|
||
|
|
default: false,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'created_at',
|
||
|
|
type: 'timestamp',
|
||
|
|
isNullable: true,
|
||
|
|
default: 'now()',
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: 'updated_at',
|
||
|
|
type: 'timestamp',
|
||
|
|
isNullable: true,
|
||
|
|
default: 'now()',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
}),
|
||
|
|
true
|
||
|
|
);
|
||
|
|
|
||
|
|
await queryRunner.createForeignKey(
|
||
|
|
'org_environment_variables',
|
||
|
|
new TableForeignKey({
|
||
|
|
columnNames: ['organization_id'],
|
||
|
|
referencedColumnNames: ['id'],
|
||
|
|
referencedTableName: 'organizations',
|
||
|
|
onDelete: 'CASCADE',
|
||
|
|
})
|
||
|
|
);
|
||
|
|
|
||
|
|
await queryRunner.createUniqueConstraint(
|
||
|
|
'org_environment_variables',
|
||
|
|
new TableUnique({
|
||
|
|
columnNames: ['variable_name', 'variable_type', 'organization_id'],
|
||
|
|
})
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public async down(queryRunner: QueryRunner): Promise<void> {}
|
||
|
|
}
|