2022-02-14 07:52:16 -06:00
|
|
|
package deltas
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func LoadAddPolicyVersion(m *sqlutil.Migrations) {
|
|
|
|
m.AddMigration(UpAddPolicyVersion, DownAddPolicyVersion)
|
|
|
|
}
|
|
|
|
|
|
|
|
func UpAddPolicyVersion(tx *sql.Tx) error {
|
2022-02-21 07:26:00 -06:00
|
|
|
_, err := tx.Exec("ALTER TABLE account_accounts ADD COLUMN policy_version TEXT;" +
|
|
|
|
"ALTER TABLE account_accounts ADD COLUMN policy_version_sent TEXT;")
|
2022-02-14 07:52:16 -06:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to execute upgrade: %w", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func DownAddPolicyVersion(tx *sql.Tx) error {
|
2022-02-21 07:26:00 -06:00
|
|
|
_, err := tx.Exec("ALTER TABLE account_accounts DROP COLUMN policy_version;" +
|
|
|
|
"ALTER TABLE account_accounts DROP COLUMN policy_version_sent;")
|
2022-02-14 07:52:16 -06:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to execute downgrade: %w", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|