Skip to content

bug: Error executing delete commands in db migration on Android #665

Description

@ov77

Plugin version:

7.0.2

Platform(s):

Android

Current behavior:

Crash on migration execution:

Open: Error in creating the databaseError: onUpgrade executeStatementProcess failed java.lang.Exception: Error: executeStatementsProcess  failed java.lang.Exception: DeleteSQL isLastModified: Database not opened

Expected behavior:

Steps to reproduce:

Add in migration a query that delete something from a table:
delete from some_table where id="something";

Related code:

export const UserUpgradeStatements = [
    {
        toVersion: 1,
        statements: [
            `CREATE TABLE IF NOT EXISTS "conversations" (
                "id" INTEGER,
                "name" TEXT DEFAULT "",
                PRIMARY KEY("id")
            ) WITHOUT ROWID;`,

            `CREATE TABLE IF NOT EXISTS "folders" (
                "id" TEXT COLLATE BINARY,
                "name" TEXT DEFAULT "",
                "order_index" INTEGER DEFAULT 0,
                PRIMARY KEY("id")
            ) WITHOUT ROWID;`,

            // folders indexes
            `CREATE INDEX IF NOT EXISTS "folders_order" ON "folders" ("order_index" asc);`,

            `CREATE TABLE "conversations_folders" (
                "conversation_id" INTEGER,
                "folder_id"	TEXT COLLATE BINARY DEFAULT NULL,
                "date" INTEGER DEFAULT 0,
                UNIQUE("conversation_id","folder_id")
            );`,
            `CREATE INDEX IF NOT EXISTS "conversations_index" ON "conversations_folders" ("conversation_id", "folder_id", "date" DESC);`
        ]
    },
    {
        toVersion: 2,
        statements: [
            `delete from conversations where id="1";`
        ]
    },
]

Other information:

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 7.4.3
  @capacitor/core: 7.4.3
  @capacitor/android: 7.4.3
  @capacitor/ios: 7.4.3

Installed Dependencies:

  @capacitor/core: 7.4.3
  @capacitor/android: 7.4.3
  @capacitor/ios: 7.4.3
  @capacitor/cli: 7.4.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions