Skip to content

Commit

Permalink
cmd: Resolves an issue with the hydra migrate command
Browse files Browse the repository at this point in the history
Closes #23
  • Loading branch information
arekkas authored and arekkas committed Jun 11, 2018
1 parent 4c30a3c commit 2b280bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/server/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func RunMigrateSQL(logger *logrus.Logger) func(cmd *cobra.Command, args []string
logger.WithField("migrations", n).WithField("table", "role").Print("Successfully applied SQL migrations")
}

if n, err := managers.policyManager.(*sql.SQLManager).CreateSchemas("", "keto_policy_migrations"); err != nil {
if n, err := managers.policyManager.(*sql.SQLManager).CreateSchemas("", "keto_policy_migration"); err != nil {
logger.WithError(err).WithField("migrations", n).WithField("table", "policies").Fatal("An error occurred while trying to apply SQL migrations")
} else {
logger.WithField("migrations", n).WithField("table", "policies").Print("Successfully applied SQL migrations")
Expand All @@ -97,7 +97,7 @@ func RunMigrateHydra(logger *logrus.Logger) func(cmd *cobra.Command, args []stri
logger.WithError(err).WithField("database_url", u.Scheme+"://*:*@"+u.Host+u.Path+"?"+u.RawQuery).Fatal("Unable to parse DATABASE_URL, make sure it has the right format")
}

migrate.SetTable("keto_legacy_hydra_migrations")
migrate.SetTable("keto_legacy_hydra_migration")
n, err := migrate.Exec(db.GetDatabase().DB, db.GetDatabase().DriverName(), legacy.HydraLegacyMigrations[db.GetDatabase().DriverName()], migrate.Up)
if err != nil {
logger.WithError(err).WithField("migrations", n).Fatal("An error occurred while trying to apply SQL migrations")
Expand Down
3 changes: 2 additions & 1 deletion legacy/hydra.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var HydraLegacyMigrations = map[string]*migrate.MemoryMigrationSource{
},
Down: []string{
`ALTER TABLE keto_role RENAME TO hydra_warden_group`,
`ALTER TABLE hydra_warden_group_member RENAME COLUMN group_id TO role_id`,
`ALTER TABLE hydra_warden_group_member RENAME COLUMN role_id TO group_id`,
`ALTER TABLE keto_role_member RENAME TO hydra_warden_group_member`,
`ALTER TABLE keto_policy_migration RENAME TO hydra_policy_migration`,
`ALTER TABLE keto_role_migration RENAME TO hydra_groups_migration`,
Expand All @@ -58,6 +58,7 @@ var HydraLegacyMigrations = map[string]*migrate.MemoryMigrationSource{
},
Down: []string{
`RENAME TABLE keto_role TO hydra_warden_group`,
`ALTER TABLE hydra_warden_group_member CHANGE role_id group_id varchar(255)`,
`RENAME TABLE keto_role_member TO hydra_warden_group_member`,
`RENAME TABLE keto_policy_migration TO hydra_policy_migration`,
`RENAME TABLE keto_role_migration TO hydra_groups_migration`,
Expand Down

0 comments on commit 2b280bb

Please sign in to comment.