mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 00:16:16 -06:00
create temporary index for the migration
This commit is contained in:
parent
db09ad1569
commit
672c63131c
1 changed files with 5 additions and 6 deletions
|
|
@ -34,22 +34,22 @@ func init() {
|
||||||
// To make update queries faster,
|
// To make update queries faster,
|
||||||
// create an index on statuses
|
// create an index on statuses
|
||||||
// that we'll drop when we're done.
|
// that we'll drop when we're done.
|
||||||
log.Info(ctx, "creating temporary index statuses_local_created_with_application_id_idx, please wait...")
|
log.Info(ctx, "creating temporary index statuses_created_with_application_id_idx, please wait...")
|
||||||
if _, err := db.
|
if _, err := db.
|
||||||
NewCreateIndex().
|
NewCreateIndex().
|
||||||
Table("statuses").
|
Table("statuses").
|
||||||
Index("statuses_local_created_with_application_id_idx").
|
Index("statuses_created_with_application_id_idx").
|
||||||
Column("local", "created_with_application_id").
|
Column("created_with_application_id").
|
||||||
IfNotExists().
|
IfNotExists().
|
||||||
Exec(ctx); err != nil {
|
Exec(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
log.Info(ctx, "cleaning up temporary index statuses_local_created_with_application_id_idx, please wait...")
|
log.Info(ctx, "cleaning up temporary index statuses_created_with_application_id_idx, please wait...")
|
||||||
if _, err := db.
|
if _, err := db.
|
||||||
NewDropIndex().
|
NewDropIndex().
|
||||||
Index("statuses_local_created_with_application_id_idx").
|
Index("statuses_created_with_application_id_idx").
|
||||||
IfExists().
|
IfExists().
|
||||||
Exec(ctx); err != nil {
|
Exec(ctx); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -131,7 +131,6 @@ func init() {
|
||||||
NewUpdate().
|
NewUpdate().
|
||||||
Table("statuses").
|
Table("statuses").
|
||||||
Set("? = ?", bun.Ident("created_with_application_id"), newAppID).
|
Set("? = ?", bun.Ident("created_with_application_id"), newAppID).
|
||||||
Where("? = ?", bun.Ident("local"), true).
|
|
||||||
Where("? = ?", bun.Ident("created_with_application_id"), oldApp.ID).
|
Where("? = ?", bun.Ident("created_with_application_id"), oldApp.ID).
|
||||||
Exec(ctx); err != nil {
|
Exec(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue