This commit is contained in:
1 parent
fcb64a34bd
commit
bbb671c5ab
9 files changed
+498
-38
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func applyTrustedSenderBlacklistSchema(ctx context.Context, exec executor, dialect Dialect) error {
|
||||
filterTypeDefinitions := map[Dialect]string{
|
||||
DialectSQLite: "TEXT NOT NULL DEFAULT 'whitelist'",
|
||||
DialectMySQL: "VARCHAR(20) NOT NULL DEFAULT 'whitelist'",
|
||||
DialectPostgres: "VARCHAR(20) NOT NULL DEFAULT 'whitelist'",
|
||||
}
|
||||
updatedAtDefinitions := map[Dialect]string{
|
||||
DialectSQLite: "DATETIME NULL",
|
||||
DialectMySQL: "DATETIME(6) NULL",
|
||||
DialectPostgres: "TIMESTAMPTZ NULL",
|
||||
}
|
||||
|
||||
ftDef, ok := filterTypeDefinitions[dialect]
|
||||
if !ok {
|
||||
return fmt.Errorf("unsupported migration dialect %q for filter_type", dialect)
|
||||
}
|
||||
if err := ensureColumn(ctx, exec, dialect, "user_trusted_sender", "filter_type", ftDef); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
upDef, ok := updatedAtDefinitions[dialect]
|
||||
if !ok {
|
||||
return fmt.Errorf("unsupported migration dialect %q for updated_at", dialect)
|
||||
}
|
||||
return ensureColumn(ctx, exec, dialect, "user_trusted_sender", "updated_at", upDef)
|
||||
}
|
||||
Reference in new issue
Block a user