chaosdorf / mete

Matekasse
MIT License
47 stars 40 forks source link

mete fails horribly on first start if the database is already existing, but empty #79

Closed YtvwlD closed 4 years ago

YtvwlD commented 5 years ago
[…]
== 20131020154048 BottleSizeAndCaffeineToInt: migrating =======================
-- change_column(:drinks, :bottle_size, :integer, {})
E, [2019-07-31T16:28:57.581783 #6] ERROR -- : Unable to record event with remote Sentry server (Raven::Error - the server responded with status 404):
/usr/local/bundle/gems/sentry-raven-2.9.0/lib/raven/transports/http.rb:34:in `rescue in send_event'
/usr/local/bundle/gems/sentry-raven-2.9.0/lib/raven/transports/http.rb:16:in `send_event'
/usr/local/bundle/gems/sentry-raven-2.9.0/lib/raven/client.rb:43:in `send_event'
/usr/local/bundle/gems/sentry-raven-2.9.0/lib/raven/instance.rb:81:in `send_event'
/usr/local/bundle/gems/sentry-raven-2.9.0/lib/raven/instance.rb:126:in `capture_type'
/usr/local/bundle/gems/sentry-raven-2.9.0/lib/raven/integrations/rake.rb:9:in `display_error_message'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:195:in `rescue in standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:185:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/usr/local/bundle/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:23:in `load'
E, [2019-07-31T16:28:57.581925 #6] ERROR -- : Failed to submit event: StandardError: An error has occurred, this and all later migrations canceled:

PG::DatatypeMismatch: ERROR:  column "bottle_size" cannot be cast automatically to type integer
HINT:  You might need to specify "USING bottle_size::integer".
: ALTER TABLE "drinks" ALTER COLUMN "bottle_size" TYPE integer
Database 'mete' already exists
rake aborted!
ActiveRecord::NoEnvironmentInSchemaError: 

Environment data not found in the schema. To resolve this issue, run: 

        bin/rails db:environment:set RAILS_ENV=production

It is completely non-obvious that the issue is that the db is already existing.

nomaster commented 5 years ago

But with Docker it should work? The entrypoint script automatically runs db migrations.

YtvwlD commented 5 years ago

I guess that's the problem here. :) The CI tests our migrations on SQLite and they work there, but they seem to fail when run on Postgres.

If the database doesn't exist, no migrations are being run - the db and all tables are being created from scratch.