Skip to content

Commit

Permalink
chore: remove sqlite migration
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Feb 28, 2024
1 parent 159621b commit d67181d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
17 changes: 1 addition & 16 deletions migrations/202402161653_initial_migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ package migrations

import (
_ "embed"
"log"

"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)

//go:embed initial_migration_postgres.sql
var initialMigrationPostgres string
//go:embed initial_migration_sqlite.sql
var initialMigrationSqlite string

var initialMigrations = map[string]string {
"postgres": initialMigrationPostgres,
"sqlite": initialMigrationSqlite,
}
var initialMigration string

// Initial migration
var _202402161653_initial_migration = &gormigrate.Migration {
Expand All @@ -25,15 +17,8 @@ var _202402161653_initial_migration = &gormigrate.Migration {
// only execute migration if subscriptions table doesn't exist
err := tx.Exec("SELECT * FROM subscriptions").Error;
if err != nil {
// find which initial migration should be executed
initialMigration := initialMigrations[tx.Dialector.Name()]
if initialMigration == "" {
log.Fatalf("unsupported database type: %s", tx.Dialector.Name())
}

return tx.Exec(initialMigration).Error
}

return nil
},
Rollback: func(tx *gorm.DB) error {
Expand Down
3 changes: 0 additions & 3 deletions migrations/initial_migration_sqlite.sql

This file was deleted.

0 comments on commit d67181d

Please sign in to comment.