Migration fails for stories_order enum
I have an old version of stringer and I just built latest image from 40e5a1f. When the container starts the logs are showing the migration is failing with the following error.
I can't tell what version I am coming from as I overwrote the old image :\
Any ideas how to workaround this or how I can see what version I used to have?
stringer | 2024-04-17 08:40:49,952 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
stringer | 2024-04-17 08:40:51,915 DEBG 'puma' stdout output:
stringer | rake aborted!
stringer | StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
stringer |
stringer | Undeclared attribute type for enum 'stories_order'. Enums must be backed by a database column or declared with an explicit type via `attribute`.
stringer |
stringer | 2024-04-17 08:40:51,915 DEBG 'puma' stdout output:
@brentcetinich sorry about that! Is there more log output with a stack trace? It looks to me like it's trying to boot the server before the migration has been run.
2024-06-03 00:14:14,304 DEBG fd 9 closed, stopped monitoring <POutputDispatcher at 140457815599376 for <Subprocess at 140457813493392 with name puma in state RUNNING> (stdout)>
2024-06-03 00:14:14,304 WARN exited: puma (exit status 1; not expected)
2024-06-03 00:14:14,304 DEBG received SIGCHLD indicating a child quit
2024-06-03 00:14:15,310 INFO spawned: 'puma' with pid 242
2024-06-03 00:14:16,313 INFO success: puma entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-06-03 00:14:19,398 DEBG 'puma' stdout output:
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
Undeclared attribute type for enum 'stories_order'. Enums must be backed by a database column or declared with an explicit type via `attribute`.
2024-06-03 00:14:19,399 DEBG 'puma' stdout output:
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/enum.rb:250:in `block in _enum'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:225:in `block in attribute'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:266:in `block in load_schema!'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:265:in `each'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:265:in `load_schema!'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/encryption/encryptable_record.rb:127:in `load_schema!'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:563:in `block in load_schema'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:560:in `synchronize'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:560:in `load_schema'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:425:in `columns_hash'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1796:in `arel_column'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1783:in `block in arel_columns'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1776:in `each'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1776:in `flat_map'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1776:in `arel_columns'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1733:in `build_select'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1591:in `build_arel'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1490:in `arel'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/finder_methods.rb:369:in `block in exists?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation.rb:1018:in `skip_query_cache_if_necessary'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/finder_methods.rb:369:in `exists?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation.rb:289:in `empty?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation.rb:316:in `any?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/querying.rb:23:in `any?'
/app/db/migrate/20230223045525_add_null_false_to_associations.rb:5:in `change'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:986:in `exec_migration'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:970:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:969:in `block in migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:227:in `with_connection'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:968:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1178:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1529:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:535:in `block in within_new_transaction'
/usr/local/bundle/gems/activesupport-7.1.3.2/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:532:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:344:in `transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1580:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1528:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1503:in `each'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1503:in `migrate_without_lock'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1448:in `block in migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1600:in `with_advisory_lock'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1448:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1274:in `up'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1249:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/tasks/database_tasks.rb:243:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/railties/databases.rake:93:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli.rb:486:in `exec'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli.rb:25:in `start'
/usr/local/bundle/gems/bundler-2.3.25/exe/bundle:48:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.3.25/exe/bundle:36:in `<top (required)>'
/usr/local/bundle/bin/bundle:25:in `load'
/usr/local/bundle/bin/bundle:25:in `<main>'
Caused by:
Undeclared attribute type for enum 'stories_order'. Enums must be backed by a database column or declared with an explicit type via `attribute`.
2024-06-03 00:14:19,402 DEBG 'puma' stdout output:
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/enum.rb:250:in `block in _enum'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:225:in `block in attribute'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:266:in `block in load_schema!'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:265:in `each'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/attributes.rb:265:in `load_schema!'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/encryption/encryptable_record.rb:127:in `load_schema!'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:563:in `block in load_schema'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:560:in `synchronize'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:560:in `load_schema'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/model_schema.rb:425:in `columns_hash'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1796:in `arel_column'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1783:in `block in arel_columns'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1776:in `each'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1776:in `flat_map'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1776:in `arel_columns'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1733:in `build_select'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1591:in `build_arel'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/query_methods.rb:1490:in `arel'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/finder_methods.rb:369:in `block in exists?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation.rb:1018:in `skip_query_cache_if_necessary'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation/finder_methods.rb:369:in `exists?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation.rb:289:in `empty?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/relation.rb:316:in `any?'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/querying.rb:23:in `any?'
/app/db/migrate/20230223045525_add_null_false_to_associations.rb:5:in `change'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:986:in `exec_migration'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:970:in `block (2 levels) in migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:969:in `block in migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:227:in `with_connection'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:968:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1178:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1529:in `block in execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:535:in `block in within_new_transaction'
/usr/local/bundle/gems/activesupport-7.1.3.2/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/transaction.rb:532:in `within_new_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:344:in `transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1580:in `ddl_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1528:in `execute_migration_in_transaction'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1503:in `each'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1503:in `migrate_without_lock'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1448:in `block in migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1600:in `with_advisory_lock'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1448:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1274:in `up'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/migration.rb:1249:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/tasks/database_tasks.rb:243:in `migrate'
/usr/local/bundle/gems/activerecord-7.1.3.2/lib/active_record/railties/databases.rake:93:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli.rb:486:in `exec'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/cli.rb:25:in `start'
/usr/local/bundle/gems/bundler-2.3.25/exe/bundle:48:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.25/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.3.25/exe/bundle:36:in `<top (required)>'
/usr/local/bundle/bin/bundle:25:in `load'
/usr/local/bundle/bin/bundle:25:in `<main>'
Running into the same issue when using the Docker container
having the same error on trying to install in docker
Upd: sent a PR with fix.
Just tried to install with Docker and getting the same error. Reproducible compose.yml and script to generate .env:
services:
stringer:
image: stringerrss/stringer:latest
container_name: stringer
restart: always
networks:
- stringer-network
ports:
- "127.0.0.1:8080:8080"
environment:
- PORT=8080
- DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@postgres/stringer
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
- ENCRYPTION_PRIMARY_KEY=${ENCRYPTION_PRIMARY_KEY}
- ENCRYPTION_DETERMINISTIC_KEY=${ENCRYPTION_DETERMINISTIC_KEY}
- ENCRYPTION_KEY_DERIVATION_SALT=${ENCRYPTION_KEY_DERIVATION_SALT}
- FETCH_FEEDS_CRON=*/5 * * * *
- CLEANUP_CRON=0 0 * * *
depends_on:
- postgres
postgres:
image: bitnami/postgresql:latest
container_name: stringer-postgres
restart: always
networks:
- stringer-network
environment:
- POSTGRESQL_DATABASE=stringer
- POSTGRESQL_USERNAME=postgres
- POSTGRESQL_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres_data:/bitnami/postgresql
networks:
stringer-network:
volumes:
postgres_data:
#!/bin/bash
# Generate random values for environment variables
SECRET_KEY_BASE=$(openssl rand -hex 64)
ENCRYPTION_PRIMARY_KEY=$(openssl rand -hex 64)
ENCRYPTION_DETERMINISTIC_KEY=$(openssl rand -hex 64)
ENCRYPTION_KEY_DERIVATION_SALT=$(openssl rand -hex 64)
POSTGRES_PASSWORD=$(openssl rand -base64 32)
# Create .env file
cat << EOF > .env
SECRET_KEY_BASE=$SECRET_KEY_BASE
ENCRYPTION_PRIMARY_KEY=$ENCRYPTION_PRIMARY_KEY
ENCRYPTION_DETERMINISTIC_KEY=$ENCRYPTION_DETERMINISTIC_KEY
ENCRYPTION_KEY_DERIVATION_SALT=$ENCRYPTION_KEY_DERIVATION_SALT
POSTGRES_PASSWORD=$POSTGRES_PASSWORD
EOF
echo ".env file created with generated values."
@volfco @Kochanac @brentcetinich can you try it again on the latest main?
@mockdeep I think they are using Docker, therefore it's harder for them to get it tested unless a new version is uploaded to the latest tag on Docker Hub (stringerrss/stringer:latest)
New docker releases should be published automatically when a branch is merged into main.
Kudos for the fix @osbre!