mirror of
https://github.com/pocketbase/pocketbase.git
synced 2024-11-28 10:03:42 +02:00
cleanup old remaining temp views
This commit is contained in:
parent
2c40811fac
commit
c9fba9972a
@ -18,6 +18,25 @@ func init() {
|
|||||||
AppMigrations.Register(func(db dbx.Builder) error {
|
AppMigrations.Register(func(db dbx.Builder) error {
|
||||||
dao := daos.New(db)
|
dao := daos.New(db)
|
||||||
|
|
||||||
|
// cleanup failed remaining/"dangling" temp views to prevent
|
||||||
|
// errors during the indexes upsert
|
||||||
|
// ---
|
||||||
|
tempViews := []string{}
|
||||||
|
viewsErr := db.Select("name").
|
||||||
|
From("sqlite_schema").
|
||||||
|
AndWhere(dbx.HashExp{"type": "view"}).
|
||||||
|
AndWhere(dbx.NewExp(`[[name]] LIKE '\_temp\_%' ESCAPE '\'`)).
|
||||||
|
Column(&tempViews)
|
||||||
|
if viewsErr != nil {
|
||||||
|
return viewsErr
|
||||||
|
}
|
||||||
|
for _, name := range tempViews {
|
||||||
|
if err := dao.DeleteView(name); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
cols, err := dao.TableColumns("_collections")
|
cols, err := dao.TableColumns("_collections")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user