capacitor-community / capacitor-community/sqlite

bug: Error executing delete commands in db migration on Android

Open
#665 1 comment 0 reactions 0 assignees View on GitHub
bug/fix needs: triage
Dominant language
Swift
Stars
661
Forks
158
PR merge metrics
No merged PRs in 30d

Description

**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

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.