mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-07 06:03:09 -06:00
Namespace migrations
This commit is contained in:
parent
26024af1f9
commit
b2ef18e708
|
|
@ -16,7 +16,6 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
|
|
@ -85,10 +84,10 @@ func NewDatabase(base *base.BaseDendrite, dbProperties *config.DatabaseOptions,
|
|||
}
|
||||
m := sqlutil.NewMigrator(d.db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "drop federationsender_rooms",
|
||||
Version: "federationsender: drop federationsender_rooms",
|
||||
Up: deltas.UpRemoveRoomsTable,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
err = m.Up(base.Context())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
package sqlite3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/matrix-org/dendrite/federationapi/storage/shared"
|
||||
|
|
@ -84,10 +83,10 @@ func NewDatabase(base *base.BaseDendrite, dbProperties *config.DatabaseOptions,
|
|||
}
|
||||
m := sqlutil.NewMigrator(d.db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "drop federationsender_rooms",
|
||||
Version: "federationsender: drop federationsender_rooms",
|
||||
Up: deltas.UpRemoveRoomsTable,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
err = m.Up(base.Context())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func NewPostgresCrossSigningSigsTable(db *sql.DB) (tables.CrossSigningSigs, erro
|
|||
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "",
|
||||
Version: "keyserver: cross signing signature indexes",
|
||||
Up: deltas.UpFixCrossSigningSignatureIndexes,
|
||||
})
|
||||
if err = m.Up(context.Background()); err != nil {
|
||||
|
|
|
|||
|
|
@ -64,12 +64,11 @@ func NewPostgresKeyChangesTable(db *sql.DB) (tables.KeyChanges, error) {
|
|||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column partition was removed from the table
|
||||
var count int
|
||||
err = db.QueryRow("SELECT partition FROM keyserver_key_changes LIMIT 1;").Scan(&count)
|
||||
err = db.QueryRow("SELECT partition FROM keyserver_key_changes LIMIT 1;").Scan()
|
||||
if err == nil {
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "refactor key changes",
|
||||
Version: "keyserver: refactor key changes",
|
||||
Up: deltas.UpRefactorKeyChanges,
|
||||
})
|
||||
return s, m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ func NewSqliteCrossSigningSigsTable(db *sql.DB) (tables.CrossSigningSigs, error)
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "",
|
||||
Version: "keyserver: cross signing signature indexes",
|
||||
Up: deltas.UpFixCrossSigningSignatureIndexes,
|
||||
})
|
||||
if err = m.Up(context.Background()); err != nil {
|
||||
|
|
|
|||
|
|
@ -61,12 +61,11 @@ func NewSqliteKeyChangesTable(db *sql.DB) (tables.KeyChanges, error) {
|
|||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column partition was removed from the table
|
||||
var count int
|
||||
err = db.QueryRow("SELECT partition FROM keyserver_key_changes LIMIT 1;").Scan(&count)
|
||||
err = db.QueryRow("SELECT partition FROM keyserver_key_changes LIMIT 1;").Scan()
|
||||
if err == nil {
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "refactor key changes",
|
||||
Version: "keyserver: refactor key changes",
|
||||
Up: deltas.UpRefactorKeyChanges,
|
||||
})
|
||||
return s, m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ func CreateMembershipTable(db *sql.DB) error {
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "add forgotten column",
|
||||
Version: "roomserver: add forgotten column",
|
||||
Up: deltas.UpAddForgottenColumn,
|
||||
})
|
||||
return m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -54,12 +54,11 @@ func Open(base *base.BaseDendrite, dbProperties *config.DatabaseOptions, cache c
|
|||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column event_nid was removed from the table
|
||||
var count int
|
||||
err = db.QueryRow("SELECT event_nid FROM roomserver_state_block LIMIT 1;").Scan(&count)
|
||||
err = db.QueryRow("SELECT event_nid FROM roomserver_state_block LIMIT 1;").Scan()
|
||||
if err == nil {
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "state blocks refactor",
|
||||
Version: "roomserver: state blocks refactor",
|
||||
Up: deltas.UpStateBlocksRefactor,
|
||||
})
|
||||
if err := m.Up(context.Background()); err != nil {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ func CreateMembershipTable(db *sql.DB) error {
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "add forgotten column",
|
||||
Version: "roomserver: add forgotten column",
|
||||
Up: deltas.UpAddForgottenColumn,
|
||||
})
|
||||
return m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -63,12 +63,11 @@ func Open(base *base.BaseDendrite, dbProperties *config.DatabaseOptions, cache c
|
|||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column event_nid was removed from the table
|
||||
var count int
|
||||
err = db.QueryRow("SELECT event_nid FROM roomserver_state_block LIMIT 1;").Scan(&count)
|
||||
err = db.QueryRow("SELECT event_nid FROM roomserver_state_block LIMIT 1;").Scan()
|
||||
if err == nil {
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "state blocks refactor",
|
||||
Version: "roomserver: state blocks refactor",
|
||||
Up: deltas.UpStateBlocksRefactor,
|
||||
})
|
||||
if err := m.Up(context.Background()); err != nil {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func NewPostgresReceiptsTable(db *sql.DB) (tables.Receipts, error) {
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "fix sequences",
|
||||
Version: "syncapi: fix sequences",
|
||||
Up: deltas.UpFixSequences,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func NewPostgresSendToDeviceTable(db *sql.DB) (tables.SendToDevice, error) {
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "drop sent_by_token",
|
||||
Version: "syncapi: drop sent_by_token",
|
||||
Up: deltas.UpRemoveSendToDeviceSentColumn,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func NewSqliteReceiptsTable(db *sql.DB, streamID *StreamIDStatements) (tables.Re
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "fix sequences",
|
||||
Version: "syncapi: fix sequences",
|
||||
Up: deltas.UpFixSequences,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func NewSqliteSendToDeviceTable(db *sql.DB) (tables.SendToDevice, error) {
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "drop sent_by_token",
|
||||
Version: "syncapi: drop sent_by_token",
|
||||
Up: deltas.UpRemoveSendToDeviceSentColumn,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -89,12 +89,12 @@ func NewPostgresAccountsTable(db *sql.DB, serverName gomatrixserverlib.ServerNam
|
|||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations([]sqlutil.Migration{
|
||||
{
|
||||
Version: "add is active",
|
||||
Version: "userapi: add is active",
|
||||
Up: deltas.UpIsActive,
|
||||
Down: deltas.DownIsActive,
|
||||
},
|
||||
{
|
||||
Version: "add account type",
|
||||
Version: "userapi: add account type",
|
||||
Up: deltas.UpAddAccountType,
|
||||
Down: deltas.DownAddAccountType,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ func NewPostgresDevicesTable(db *sql.DB, serverName gomatrixserverlib.ServerName
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "add last_seen_ts",
|
||||
Version: "userapi: add last_seen_ts",
|
||||
Up: deltas.UpLastSeenTSIP,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
|
|
|
|||
|
|
@ -91,12 +91,12 @@ func NewSQLiteAccountsTable(db *sql.DB, serverName gomatrixserverlib.ServerName)
|
|||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations([]sqlutil.Migration{
|
||||
{
|
||||
Version: "add is active",
|
||||
Version: "userapi: add is active",
|
||||
Up: deltas.UpIsActive,
|
||||
Down: deltas.DownIsActive,
|
||||
},
|
||||
{
|
||||
Version: "add account type",
|
||||
Version: "userapi: add account type",
|
||||
Up: deltas.UpAddAccountType,
|
||||
Down: deltas.DownAddAccountType,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ func NewSQLiteDevicesTable(db *sql.DB, serverName gomatrixserverlib.ServerName)
|
|||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(sqlutil.Migration{
|
||||
Version: "add last_seen_ts",
|
||||
Version: "userapi: add last_seen_ts",
|
||||
Up: deltas.UpLastSeenTSIP,
|
||||
})
|
||||
if err = m.Up(context.Background()); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue