Skip to content

Commit

Permalink
Add squashed migrations (#397)
Browse files Browse the repository at this point in the history
The goal is to get rid of all `.sql` based operations and files. This
changes creates a "squashed" migration containing the current snapshot
of the schema
  • Loading branch information
srikanthccv authored Sep 16, 2024
1 parent f3af05c commit 4d5843d
Show file tree
Hide file tree
Showing 4 changed files with 2,660 additions and 24 deletions.
45 changes: 21 additions & 24 deletions cmd/signozschemamigrator/schema_migrator/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,13 @@ func (m *MigrationManager) runSquashedMigrationsForLogs(ctx context.Context) err
return nil
}
m.logger.Info("Running squashed migrations for logs")
// TODO(srikanthccv): enable in upcoming PR
// for _, migration := range SquashedLogsMigrations {
// for _, item := range migration.UpItems {
// if err := m.RunOperation(ctx, item, migration.MigrationID, "signoz_logs", false); err != nil {
// return err
// }
// }
// }
for _, migration := range SquashedLogsMigrations {
for _, item := range migration.UpItems {
if err := m.RunOperation(ctx, item, migration.MigrationID, "signoz_logs", false); err != nil {
return err
}
}
}
m.logger.Info("Squashed migrations for logs completed")
return nil
}
Expand All @@ -230,14 +229,13 @@ func (m *MigrationManager) runSquashedMigrationsForMetrics(ctx context.Context)
return nil
}
m.logger.Info("Running squashed migrations for metrics")
// TODO(srikanthccv): enable in upcoming PR
// for _, migration := range SquashedMetricsMigrations {
// for _, item := range migration.UpItems {
// if err := m.RunOperation(ctx, item, migration.MigrationID, signozMetricsDB, false); err != nil {
// return err
// }
// }
// }
for _, migration := range SquashedMetricsMigrations {
for _, item := range migration.UpItems {
if err := m.RunOperation(ctx, item, migration.MigrationID, signozMetricsDB, false); err != nil {
return err
}
}
}
m.logger.Info("Squashed migrations for metrics completed")
return nil
}
Expand All @@ -252,14 +250,13 @@ func (m *MigrationManager) runSquashedMigrationsForTraces(ctx context.Context) e
return nil
}
m.logger.Info("Running squashed migrations for traces")
// TODO(srikanthccv): enable in upcoming PR
// for _, migration := range SquashedTracesMigrations {
// for _, item := range migration.UpItems {
// if err := m.RunOperation(ctx, item, migration.MigrationID, signozTracesDB, false); err != nil {
// return err
// }
// }
// }
for _, migration := range SquashedTracesMigrations {
for _, item := range migration.UpItems {
if err := m.RunOperation(ctx, item, migration.MigrationID, signozTracesDB, false); err != nil {
return err
}
}
}
m.logger.Info("Squashed migrations for traces completed")
return nil
}
Expand Down
Loading

0 comments on commit 4d5843d

Please sign in to comment.