From f4244a36c6e829b473077aef60c204b7990e727e Mon Sep 17 00:00:00 2001 From: Adish M Date: Thu, 10 Jul 2025 14:50:57 +0530 Subject: [PATCH 1/2] Cloud imgration issue fix --- ...1750927057649-AddAiGenerationFlagsInApp.ts | 62 -------------- .../1750927083207-AddArtifactsTable.ts | 81 ------------------- 2 files changed, 143 deletions(-) delete mode 100644 server/data-migrations/1750927057649-AddAiGenerationFlagsInApp.ts delete mode 100644 server/data-migrations/1750927083207-AddArtifactsTable.ts diff --git a/server/data-migrations/1750927057649-AddAiGenerationFlagsInApp.ts b/server/data-migrations/1750927057649-AddAiGenerationFlagsInApp.ts deleted file mode 100644 index 3205c9979b..0000000000 --- a/server/data-migrations/1750927057649-AddAiGenerationFlagsInApp.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; - -export class AddAiGenerationFlagsInApp1750927057649 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - // Add is_initialised_from_prompt column - await queryRunner.addColumn( - 'apps', - new TableColumn({ - name: 'is_initialised_from_prompt', - type: 'boolean', - default: false, - isNullable: false, - }) - ); - - // Add app_generated_from_prompt column - await queryRunner.addColumn( - 'apps', - new TableColumn({ - name: 'app_generated_from_prompt', - type: 'boolean', - default: false, - isNullable: false, - }) - ); - - // Add ai_generation_metadata column - await queryRunner.addColumn( - 'apps', - new TableColumn({ - name: 'ai_generation_metadata', - type: 'jsonb', - isNullable: true, - }) - ); - - // Create app_builder_mode enum type - await queryRunner.query(`CREATE TYPE "app_builder_mode" AS ENUM ('ai', 'visual')`); - - // Add app_builder_mode column - await queryRunner.addColumn( - 'apps', - new TableColumn({ - name: 'app_builder_mode', - type: 'app_builder_mode', - default: "'visual'", - isNullable: false, - }) - ); - } - - public async down(queryRunner: QueryRunner): Promise { - // Remove columns in reverse order - await queryRunner.dropColumn('apps', 'app_builder_mode'); - await queryRunner.query('DROP TYPE "app_builder_mode"'); - await queryRunner.dropColumn('apps', 'ai_generation_metadata'); - await queryRunner.dropColumn('apps', 'app_generated_from_prompt'); - await queryRunner.dropColumn('apps', 'is_initialised_from_prompt'); - } - -} diff --git a/server/data-migrations/1750927083207-AddArtifactsTable.ts b/server/data-migrations/1750927083207-AddArtifactsTable.ts deleted file mode 100644 index 078c3412aa..0000000000 --- a/server/data-migrations/1750927083207-AddArtifactsTable.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm"; - -export class AddArtifactsTable1750927083207 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.createTable( - new Table({ - name: 'artifacts', - columns: [ - { - name: 'id', - type: 'uuid', - isPrimary: true, - isGenerated: true, - generationStrategy: 'uuid', - }, - { - name: 'conversation_id', - type: 'uuid', - isNullable: false, - }, - { - name: 'message_id', - type: 'uuid', - isNullable: false, - }, - { - name: 'content', - type: 'jsonb', - isNullable: false, - }, - { - name: 'identifier', - type: 'varchar', - isNullable: false, - }, - { - name: 'created_at', - type: 'timestamp', - default: 'now()', - }, - { - name: 'updated_at', - type: 'timestamp', - default: 'now()', - }, - ], - }), - true, - ); - - await queryRunner.createForeignKey( - 'artifacts', - new TableForeignKey({ - columnNames: ['conversation_id'], - referencedColumnNames: ['id'], - referencedTableName: 'ai_conversations', - onDelete: 'CASCADE', - }), - ); - - await queryRunner.createForeignKey( - 'artifacts', - new TableForeignKey({ - columnNames: ['message_id'], - referencedColumnNames: ['id'], - referencedTableName: 'ai_conversation_messages', - onDelete: 'CASCADE', - }), - ); - } - - public async down(queryRunner: QueryRunner): Promise { - const table = await queryRunner.getTable('artifacts'); - if (table) { - const foreignKeys = table.foreignKeys; - await Promise.all(foreignKeys.map(foreignKey => queryRunner.dropForeignKey('artifacts', foreignKey))); - } - await queryRunner.dropTable('artifacts'); - } -} From d38eb7a6f220878459215aa96dc03443bdcb4b85 Mon Sep 17 00:00:00 2001 From: Adish M Date: Thu, 10 Jul 2025 14:52:32 +0530 Subject: [PATCH 2/2] added the correct files for migration --- ...1748331051836-AddAiGenerationFlagsInApp.ts | 60 ++++++++++++++ .../1748542504137-AddArtifactsTable.ts | 80 +++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 server/data-migrations/1748331051836-AddAiGenerationFlagsInApp.ts create mode 100644 server/data-migrations/1748542504137-AddArtifactsTable.ts diff --git a/server/data-migrations/1748331051836-AddAiGenerationFlagsInApp.ts b/server/data-migrations/1748331051836-AddAiGenerationFlagsInApp.ts new file mode 100644 index 0000000000..2f55d6fbbe --- /dev/null +++ b/server/data-migrations/1748331051836-AddAiGenerationFlagsInApp.ts @@ -0,0 +1,60 @@ +import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; + +export class AddAiGenerationFlagsInApp1748331051836 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + // Add is_initialised_from_prompt column + await queryRunner.addColumn( + 'apps', + new TableColumn({ + name: 'is_initialised_from_prompt', + type: 'boolean', + default: false, + isNullable: false, + }) + ); + + // Add app_generated_from_prompt column + await queryRunner.addColumn( + 'apps', + new TableColumn({ + name: 'app_generated_from_prompt', + type: 'boolean', + default: false, + isNullable: false, + }) + ); + + // Add ai_generation_metadata column + await queryRunner.addColumn( + 'apps', + new TableColumn({ + name: 'ai_generation_metadata', + type: 'jsonb', + isNullable: true, + }) + ); + + // Create app_builder_mode enum type + await queryRunner.query(`CREATE TYPE "app_builder_mode" AS ENUM ('ai', 'visual')`); + + // Add app_builder_mode column + await queryRunner.addColumn( + 'apps', + new TableColumn({ + name: 'app_builder_mode', + type: 'app_builder_mode', + default: "'visual'", + isNullable: false, + }) + ); + } + + public async down(queryRunner: QueryRunner): Promise { + // Remove columns in reverse order + await queryRunner.dropColumn('apps', 'app_builder_mode'); + await queryRunner.query('DROP TYPE "app_builder_mode"'); + await queryRunner.dropColumn('apps', 'ai_generation_metadata'); + await queryRunner.dropColumn('apps', 'app_generated_from_prompt'); + await queryRunner.dropColumn('apps', 'is_initialised_from_prompt'); + } +} diff --git a/server/data-migrations/1748542504137-AddArtifactsTable.ts b/server/data-migrations/1748542504137-AddArtifactsTable.ts new file mode 100644 index 0000000000..2c66977be8 --- /dev/null +++ b/server/data-migrations/1748542504137-AddArtifactsTable.ts @@ -0,0 +1,80 @@ +import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm'; + +export class AddArtifactsTable1748542504137 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.createTable( + new Table({ + name: 'artifacts', + columns: [ + { + name: 'id', + type: 'uuid', + isPrimary: true, + isGenerated: true, + generationStrategy: 'uuid', + }, + { + name: 'conversation_id', + type: 'uuid', + isNullable: false, + }, + { + name: 'message_id', + type: 'uuid', + isNullable: false, + }, + { + name: 'content', + type: 'jsonb', + isNullable: false, + }, + { + name: 'identifier', + type: 'varchar', + isNullable: false, + }, + { + name: 'created_at', + type: 'timestamp', + default: 'now()', + }, + { + name: 'updated_at', + type: 'timestamp', + default: 'now()', + }, + ], + }), + true, + ); + + await queryRunner.createForeignKey( + 'artifacts', + new TableForeignKey({ + columnNames: ['conversation_id'], + referencedColumnNames: ['id'], + referencedTableName: 'ai_conversations', + onDelete: 'CASCADE', + }), + ); + + await queryRunner.createForeignKey( + 'artifacts', + new TableForeignKey({ + columnNames: ['message_id'], + referencedColumnNames: ['id'], + referencedTableName: 'ai_conversation_messages', + onDelete: 'CASCADE', + }), + ); + } + + public async down(queryRunner: QueryRunner): Promise { + const table = await queryRunner.getTable('artifacts'); + if (table) { + const foreignKeys = table.foreignKeys; + await Promise.all(foreignKeys.map(foreignKey => queryRunner.dropForeignKey('artifacts', foreignKey))); + } + await queryRunner.dropTable('artifacts'); + } +}