mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 06:18:34 +00:00
70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
|
|
|
|
export class CreateAIChatPrompts1739252958127 implements MigrationInterface {
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.createTable(
|
|
new Table({
|
|
name: 'ai_chat_prompts',
|
|
columns: [
|
|
{
|
|
name: 'id',
|
|
type: 'uuid',
|
|
isPrimary: true,
|
|
generationStrategy: 'uuid',
|
|
default: 'gen_random_uuid()',
|
|
},
|
|
{
|
|
name: 'prompt',
|
|
type: 'json',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'response',
|
|
type: 'json',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'provider',
|
|
type: 'enum',
|
|
enum: ['openai', 'claude'],
|
|
},
|
|
{
|
|
name: 'operation_id',
|
|
type: 'varchar',
|
|
},
|
|
{
|
|
name: 'organization_id',
|
|
type: 'uuid',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'selfhost_customer_id',
|
|
type: 'uuid',
|
|
isNullable: true,
|
|
},
|
|
{
|
|
name: 'credits_used',
|
|
type: 'int',
|
|
default: 0,
|
|
},
|
|
{
|
|
name: 'created_at',
|
|
type: 'timestamp',
|
|
default: 'CURRENT_TIMESTAMP',
|
|
},
|
|
{
|
|
name: 'updated_at',
|
|
type: 'timestamp',
|
|
default: 'CURRENT_TIMESTAMP',
|
|
onUpdate: 'CURRENT_TIMESTAMP',
|
|
},
|
|
],
|
|
}),
|
|
true
|
|
);
|
|
}
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
await queryRunner.dropTable('ai_chat_prompts');
|
|
}
|
|
}
|