You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
query:=`SELECT name FROM sqlite_master WHERE type = 'table';`
This leads to the error "table sqlite_sequence may not be dropped" if AUTOINCREMENT fields are used and records created.
In general it might be best to ignore tables starting with sqlite_ since they can not be created using create table and probably don't need to be deleted. In case of sqlite_sequence sqlite will remove entries entries if the respective table is removed so there is no need for any cleanup either. That's probably the same for the sqlite_stat* tables created by ANALYZE and so on.
The query for the tables to be dropped could look like this: SELECT name FROM sqlite_master WHERE type = 'table' and name not like 'sqlite_%';
The text was updated successfully, but these errors were encountered:
makadev
changed the title
sqlite3 Drop() attempts to drop interal tables which might fail f.e. for sqlite_sequence
sqlite3 Drop() attempts to drop internal tables which might fail f.e. for sqlite_sequence
Aug 23, 2024
As per Documentation if there is an
AUTOINCREMENT
column sqlite creates an internal table calledsqlite_sequence
. This table can't be dropped.Using
Drop()
with the sqlite3 migration driver simply attempts do delete every table found insqlite_master
migrate/database/sqlite3/sqlite3.go
Line 137 in 0c456c4
This leads to the error "table sqlite_sequence may not be dropped" if AUTOINCREMENT fields are used and records created.
In general it might be best to ignore tables starting with
sqlite_
since they can not be created using create table and probably don't need to be deleted. In case ofsqlite_sequence
sqlite will remove entries entries if the respective table is removed so there is no need for any cleanup either. That's probably the same for thesqlite_stat*
tables created byANALYZE
and so on.The query for the tables to be dropped could look like this:
SELECT name FROM sqlite_master WHERE type = 'table' and name not like 'sqlite_%';
The text was updated successfully, but these errors were encountered: