Skip to content

Commit

Permalink
services/horizon: Add --skip-migrations-check flag (stellar#3557)
Browse files Browse the repository at this point in the history
This commit adds `--skip-migrations-check` flag that, when set, will skip
checking if there are any migrations required to start Horizon.

When checking if there are any migrations required Horizon calls
`migrate.PlanMigration` which sends `CREATE TABLE gorp_migrations`. This query
is forbidden when using read only database (like replica).
  • Loading branch information
bartekn authored Apr 21, 2021
1 parent dcfb699 commit 7c92b23
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions services/horizon/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type Config struct {
// ApplyMigrations will apply pending migrations to the horizon database
// before starting the horizon service
ApplyMigrations bool
// SkipMigrationsCheck will skip checking if there are any migrations
// required
SkipMigrationsCheck bool
// CheckpointFrequency establishes how many ledgers exist between checkpoints
CheckpointFrequency uint32
// BehindCloudflare determines if Horizon instance is behind Cloudflare. In
Expand Down
12 changes: 11 additions & 1 deletion services/horizon/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ func Flags() (*Config, support.ConfigOptions) {
Required: false,
Usage: "applies pending migrations before starting horizon",
},
&support.ConfigOption{
Name: "skip-migrations-check",
ConfigKey: &config.SkipMigrationsCheck,
OptType: types.Bool,
FlagDefault: false,
Required: false,
Usage: "skips checking if there are migrations required",
},
&support.ConfigOption{
Name: "checkpoint-frequency",
ConfigKey: &config.CheckpointFrequency,
Expand Down Expand Up @@ -443,7 +451,9 @@ func ApplyFlags(config *Config, flags support.ConfigOptions) {
}

// Migrations should be checked as early as possible
checkMigrations(*config)
if !config.SkipMigrationsCheck {
checkMigrations(*config)
}

// Validate options that should be provided together
validateBothOrNeither("tls-cert", "tls-key")
Expand Down

0 comments on commit 7c92b23

Please sign in to comment.