diff --git a/store/db/db.go b/store/db/db.go index 24cd75f8..ebf7a941 100644 --- a/store/db/db.go +++ b/store/db/db.go @@ -43,7 +43,7 @@ func (db *DB) Open(ctx context.Context) (err error) { } // Connect to the database. - sqlDB, err := sql.Open("sqlite3", db.profile.DSN) + sqlDB, err := sql.Open("sqlite3", db.profile.DSN+"?_foreign_keys=1") if err != nil { return fmt.Errorf("failed to open db with dsn: %s, err: %w", db.profile.DSN, err) } diff --git a/store/memo.go b/store/memo.go index 031faa44..17668113 100644 --- a/store/memo.go +++ b/store/memo.go @@ -354,7 +354,6 @@ func findMemoRawList(ctx context.Context, tx *sql.Tx, find *api.MemoFind) ([]*me func deleteMemo(ctx context.Context, tx *sql.Tx, delete *api.MemoDelete) error { result, err := tx.ExecContext(ctx, ` - PRAGMA foreign_keys = ON; DELETE FROM memo WHERE id = ? `, delete.ID) if err != nil { diff --git a/store/resource.go b/store/resource.go index 06154354..3ea5db3a 100644 --- a/store/resource.go +++ b/store/resource.go @@ -241,7 +241,6 @@ func findResourceList(ctx context.Context, tx *sql.Tx, find *api.ResourceFind) ( func deleteResource(ctx context.Context, tx *sql.Tx, delete *api.ResourceDelete) error { result, err := tx.ExecContext(ctx, ` - PRAGMA foreign_keys = ON; DELETE FROM resource WHERE id = ? AND creator_id = ? `, delete.ID, delete.CreatorID) if err != nil { diff --git a/store/shortcut.go b/store/shortcut.go index 0eab5c91..2fae474a 100644 --- a/store/shortcut.go +++ b/store/shortcut.go @@ -288,7 +288,6 @@ func findShortcutList(ctx context.Context, tx *sql.Tx, find *api.ShortcutFind) ( func deleteShortcut(ctx context.Context, tx *sql.Tx, delete *api.ShortcutDelete) error { result, err := tx.ExecContext(ctx, ` - PRAGMA foreign_keys = ON; DELETE FROM shortcut WHERE id = ? `, delete.ID) if err != nil { diff --git a/store/user.go b/store/user.go index dc3a34c3..1bff2586 100644 --- a/store/user.go +++ b/store/user.go @@ -351,7 +351,6 @@ func findUserList(ctx context.Context, tx *sql.Tx, find *api.UserFind) ([]*userR func deleteUser(ctx context.Context, tx *sql.Tx, delete *api.UserDelete) error { result, err := tx.ExecContext(ctx, ` - PRAGMA foreign_keys = ON; DELETE FROM user WHERE id = ? `, delete.ID) if err != nil {