getredash / contrib-helm-chart

Community maintained Redash Helm Chart
Apache License 2.0
163 stars 143 forks source link

The database migrations are not happen during helm chart installation #187

Open zentavr opened 3 months ago

zentavr commented 3 months ago

We migrated from the hosted installation into K8S using this chart, thank you for your work! During the migration we copy-pasted PostgreSQL database and had noticed that the helm chart not performs the database migration.

In order to fix that, we run that manually:

redash@ds-redash-848b4c68d-grpzg:/app$ /app/manage.py db --help
Usage: manage.py db [OPTIONS] COMMAND [ARGS]...

  Perform database migrations.

Options:
  --help  Show this message and exit.

Commands:
  branches   Show current branch points
  current    Display the current revision for each database.
  downgrade  Revert to a previous version
  edit       Edit a revision file
  heads      Show current available heads in the script directory
  history    List changeset scripts in chronological order.
  init       Creates a new migration repository.
  merge      Merge two revisions together, creating a new revision file
  migrate    Autogenerate a new revision file (Alias for 'revision...
  revision   Create a new revision file.
  show       Show the revision denoted by the given symbol.
  stamp      'stamp' the revision table with the given revision; don't...
  upgrade    Upgrade to a later version
redash@ds-redash-848b4c68d-grpzg:/app$ /app/manage.py db migrate
[2024-08-31 15:14:23,555][PID:66][INFO][xmlschema] Resource 'XMLSchema.xsd' is already loaded
[2024-08-31 15:14:25,440][PID:66][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2024-08-31 15:14:25,440][PID:66][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2024-08-31 15:14:25,458][PID:66][ERROR][root] Error: Target database is not up to date.
redash@ds-redash-848b4c68d-grpzg:/app$ /app/manage.py db upgrade
[2024-08-31 15:15:06,644][PID:73][INFO][xmlschema] Resource 'XMLSchema.xsd' is already loaded
[2024-08-31 15:15:08,475][PID:73][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2024-08-31 15:15:08,475][PID:73][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2024-08-31 15:15:08,482][PID:73][INFO][alembic.runtime.migration] Running upgrade 89bc7873a3e0 -> fd4fc850d7ea, Convert user details to jsonb and move user profile image url into details column
[2024-08-31 15:15:08,501][PID:73][INFO][alembic.runtime.migration] Running upgrade fd4fc850d7ea -> 1038c2174f5d, Make case insensitive hash of query text
[2024-08-31 15:15:08,849][PID:73][INFO][alembic.runtime.migration] Running upgrade 1038c2174f5d -> 7ce5925f832b, create sqlalchemy_searchable expressions
[2024-08-31 15:15:08,853][PID:73][INFO][alembic.runtime.migration] Running upgrade 7ce5925f832b -> 7205816877ec, change type of json fields from varchar to json
redash@ds-redash-848b4c68d-grpzg:/app$ /app/manage.py db migrate
[2024-08-31 15:15:39,471][PID:80][INFO][xmlschema] Resource 'XMLSchema.xsd' is already loaded
[2024-08-31 15:15:41,459][PID:80][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2024-08-31 15:15:41,459][PID:80][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2024-08-31 15:15:41,480][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'data_source_groups_id_seq' as owned by integer column 'data_source_groups(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,565][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'api_keys_id_seq' as owned by integer column 'api_keys(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,653][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'query_results_id_seq' as owned by integer column 'query_results(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,665][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'queries_id_seq' as owned by integer column 'queries(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,739][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'alerts_id_seq' as owned by integer column 'alerts(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,750][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'changes_id_seq' as owned by integer column 'changes(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,761][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'visualizations_id_seq' as owned by integer column 'visualizations(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,838][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'events_id_seq' as owned by integer column 'events(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,850][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'widgets_id_seq' as owned by integer column 'widgets(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,938][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'alert_subscriptions_id_seq' as owned by integer column 'alert_subscriptions(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,960][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'access_permissions_id_seq' as owned by integer column 'access_permissions(id)', assuming SERIAL and omitting
[2024-08-31 15:15:41,971][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'query_snippets_id_seq' as owned by integer column 'query_snippets(id)', assuming SERIAL and omitting
[2024-08-31 15:15:42,047][PID:80][INFO][alembic.ddl.postgresql] Detected sequence named 'favorites_id_seq' as owned by integer column 'favorites(id)', assuming SERIAL and omitting
[2024-08-31 15:15:42,142][PID:80][INFO][alembic.autogenerate.compare] Detected NOT NULL on column 'organizations.settings'
[2024-08-31 15:15:42,148][PID:80][INFO][alembic.autogenerate.compare] Detected NOT NULL on column 'queries.options'
[2024-08-31 15:15:42,150][PID:80][INFO][alembic.autogenerate.compare] Detected NULL on column 'query_results.data'
[2024-08-31 15:15:42,159][PID:80][INFO][alembic.autogenerate.compare] Detected NULL on column 'visualizations.options'
  Generating /app/migrations/versions/0150baadf266_.py ...  done
redash@ds-redash-848b4c68d-grpzg:/app$ 

I wonder if this should be a part of the kind: Job which is being triggered during the installation?