Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Add LAGO_CLICKHOUSE_MIGRATIONS_ENABLED env #2281

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/migrations-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
LAGO_FROM_EMAIL: [email protected]
LAGO_CLICKHOUSE_ENABLED: true
LAGO_CLICKHOUSE_MIGRATIONS_ENABLED: true
LAGO_CLICKHOUSE_HOST: localhost
LAGO_CLICKHOUSE_DATABASE: default
LAGO_CLICKHOUSE_USERNAME: ""
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
LAGO_FROM_EMAIL: [email protected]
LAGO_CLICKHOUSE_ENABLED: true
LAGO_CLICKHOUSE_MIGRATIONS_ENABLED: true
LAGO_CLICKHOUSE_HOST: localhost
LAGO_CLICKHOUSE_DATABASE: default
LAGO_CLICKHOUSE_USERNAME: ""
Expand Down
8 changes: 4 additions & 4 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ development:
password: default
migrations_paths: db/clickhouse_migrate
debug: true
database_tasks: <% if ENV['LAGO_CLICKHOUSE_ENABLED'].present? %> true <% else %> false <% end %>
database_tasks: <% if ENV['LAGO_CLICKHOUSE_MIGRATIONS_ENABLED'].present? %> true <% else %> false <% end %>

test:
primary:
Expand All @@ -46,7 +46,7 @@ test:
password: <%= ENV.fetch('LAGO_CLICKHOUSE_PASSWORD', 'default') %>
migrations_paths: db/clickhouse_migrate
debug: true
database_tasks: <% if ENV['LAGO_CLICKHOUSE_ENABLED'].present? %> true <% else %> false <% end %>
database_tasks: <% if ENV['LAGO_CLICKHOUSE_MIGRATIONS_ENABLED'].present? %> true <% else %> false <% end %>
schema_dump: <% if ENV['LAGO_DISABLE_SCHEMA_DUMP'].present? %> false <% else %> clickhouse_schema.rb <% end %>

staging:
Expand All @@ -66,7 +66,7 @@ staging:
password: <%= ENV['LAGO_CLICKHOUSE_PASSWORD'] %>
migrations_paths: db/clickhouse_migrate
debug: false
database_tasks: <% if ENV['LAGO_CLICKHOUSE_ENABLED'].present? %> true <% else %> false <% end %>
database_tasks: <% if ENV['LAGO_CLICKHOUSE_MIGRATIONS_ENABLED'].present? %> true <% else %> false <% end %>

production:
primary:
Expand All @@ -92,4 +92,4 @@ production:
ssl: <%= ENV.fetch('LAGO_CLICKHOUSE_SSL', false) %>
migrations_paths: db/clickhouse_migrate
debug: false
database_tasks: <% if ENV['LAGO_CLICKHOUSE_ENABLED'].present? %> true <% else %> false <% end %>
database_tasks: <% if ENV['LAGO_CLICKHOUSE_MIGRATIONS_ENABLED'].present? %> true <% else %> false <% end %>
2 changes: 1 addition & 1 deletion lib/tasks/lago.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace :lago do
schema_version: ApplicationRecord.connection.migration_context.current_version
}

if ENV['LAGO_CLICKHOUSE_ENABLED'] == "true"
if ENV['LAGO_CLICKHOUSE_MIGRATIONS_ENABLED'] == "true"
output[:clickhouse_schema_version] = Clickhouse::BaseRecord.connection.migration_context.current_version
end

Expand Down
4 changes: 2 additions & 2 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ fi

rm -f ./tmp/pids/server.pid

if [ -v LAGO_CLICKHOUSE_ENABLED ] && [ "$LAGO_CLICKHOUSE_ENABLED" == "true" ]
if [ -v LAGO_CLICKHOUSE_MIGRATIONS_ENABLED ] && [ "$LAGO_CLICKHOUSE_MIGRATIONS_ENABLED" == "true" ]
then
bundle exec rails db:migrate:primary
bundle exec rake db:migrate:clickhouse
bundle exec rails db:migrate:clickhouse
else
bundle exec rails db:migrate
fi
Expand Down