FlowiseAI / Flowise

Drag & drop UI to build your customized LLM flow

Home Page:https://flowiseai.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Postgres AddDocumentStore migration appears to be broken

automaton82 opened this issue · comments

Describe the bug
If you run the latest release that just went out against a Postgres database you'll get the following error (Windows native build):

2024-05-06 18:07:33 [INFO]: Starting Flowise...
2024-05-06 18:07:33 [INFO]: ⚡️ [server]: Flowise Server is listening at 3000
2024-05-06 18:07:33 [INFO]: 📦 [server]: Data Source is initializing...
Migration "AddDocumentStore1711637331047" failed, error: column "docid" does not exist
2024-05-06 18:07:33 [ERROR]: ❌ [server]: Error during Data Source initialization: column "docid" does not exist
QueryFailedError: column "docid" does not exist
    at PostgresQueryRunner.query (C:\git\flowise\node_modules\.pnpm\typeorm@0.3.20_ioredis@5.3.2_mongodb@6.3.0_gcp-metadata@6.1.0_encoding@0.1.13__socks@2.8.1__m_zcrllk56icfjtqwqvaoc2j6pya\node_modules\typeorm\driver\postgres\PostgresQueryRunner.js:219:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async AddDocumentStore1711637331047.up (C:\git\flowise\packages\server\dist\database\migrations\postgres\1711637331047-AddDocumentStore.js:26:9)
    at async MigrationExecutor.executePendingMigrations (C:\git\flowise\node_modules\.pnpm\typeorm@0.3.20_ioredis@5.3.2_mongodb@6.3.0_gcp-metadata@6.1.0_encoding@0.1.13__socks@2.8.1__m_zcrllk56icfjtqwqvaoc2j6pya\node_modules\typeorm\migration\MigrationExecutor.js:225:17)
    at async DataSource.runMigrations (C:\git\flowise\node_modules\.pnpm\typeorm@0.3.20_ioredis@5.3.2_mongodb@6.3.0_gcp-metadata@6.1.0_encoding@0.1.13__socks@2.8.1__m_zcrllk56icfjtqwqvaoc2j6pya\node_modules\typeorm\data-source\DataSource.js:265:35)
    at async C:\git\flowise\packages\server\dist\index.js:62:13
2024-05-06 18:07:35 [INFO]: Shutting down Flowise...

To Reproduce
Steps to reproduce the behavior:

  1. Pull latest and build it on Windows
  2. Update .env to point to an older Postgres database
  3. Run it

Expected behavior
Should work.

Setup

  • Native windows pnpm start build
  • Flowise Version latest from changeset a84eabb
  • OS: Windows 11

Additional context
@HenryHengZJ I think the problem is in the the 1711637331047-AddDocumentStore.ts file. If you change the following lines:

        await queryRunner.query(
            `CREATE INDEX IF NOT EXISTS "IDX_e76bae1780b77e56aab1h2asd4" ON document_store_file_chunk USING btree (docId);`
        )
        await queryRunner.query(
            `CREATE INDEX IF NOT EXISTS "IDX_e213b811b01405a42309a6a410" ON document_store_file_chunk USING btree (storeId);`
        )

And escape the column names like they are on Sqlite and MySQL:

        await queryRunner.query(
            `CREATE INDEX IF NOT EXISTS "IDX_e76bae1780b77e56aab1h2asd4" ON document_store_file_chunk USING btree ("docId");`
        )
        await queryRunner.query(
            `CREATE INDEX IF NOT EXISTS "IDX_e213b811b01405a42309a6a410" ON document_store_file_chunk USING btree ("storeId");`
        )

It will run without an error and create the new tables properly.

commented

I just ran into this issue with my local but it's a mac. Made your simple change and now the migration completed successfully for my postgres db. I did run pnpm typeorm:migration-run in the server directory, so not sure if it worked for the root script.

I see, didnt know we need to escape that with ""