fix: test migration cleanup for discount types/tables, fix type ordering in init-script

- Add new discount types to testdb.Migrate drop list (campaign_type, milestone_type, etc.)
- Add new discount tables to testdb.Migrate drop order and TruncateTables
- Move discount type definitions to top of init-script.sql with other enums
- Remove duplicate type definitions that were after admin_notification_reason
- Types must be defined before tables that reference them
This commit is contained in:
2026-05-08 19:59:18 +01:00
parent 79a794de58
commit 968b40b4d9
2 changed files with 16 additions and 7 deletions
+11
View File
@@ -77,6 +77,11 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) {
"DROP TYPE IF EXISTS booking_status CASCADE",
"DROP TYPE IF EXISTS verification_purpose CASCADE",
"DROP TYPE IF EXISTS admin_notification_reason CASCADE",
"DROP TYPE IF EXISTS campaign_type CASCADE",
"DROP TYPE IF EXISTS milestone_type CASCADE",
"DROP TYPE IF EXISTS milestone_unit CASCADE",
"DROP TYPE IF EXISTS discount_campaign_scope CASCADE",
"DROP TYPE IF EXISTS discount_campaign_status CASCADE",
}
for _, stmt := range typeDrops {
if _, err := pool.Exec(ctx, stmt); err != nil {
@@ -86,6 +91,9 @@ func Migrate(t *testing.T, pool *pgxpool.Pool) {
// Drop all tables, sequences, and views in correct order
dropOrder := []string{
"booking_discounts",
"loyalty_redemptions",
"discount_campaigns",
"forgiven_no_shows",
"admin_notifications",
"user_notification_preferences",
@@ -187,6 +195,9 @@ func TruncateTables(t *testing.T, pool *pgxpool.Pool) {
ctx := context.Background()
tables := []string{
"booking_discounts",
"loyalty_redemptions",
"discount_campaigns",
"forgiven_no_shows",
"user_social_logins",
"verification_codes",