Latest Docker version `relation "snippet_files" does not exist`
ils13 opened this issue · comments
ils13 commented
Hey today I noticed my snibox was all empty, and upon further inspection I noticed the following error, in the db logs.
ERROR: relation "snippet_files" does not exist at character 566,
STATEMENT: SELECT a.attname, format_type(a.atttypid, a.atttypmod),,
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,,
c.collname, col_description(a.attrelid, a.attnum) AS comment,
FROM pg_attribute a,
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum,
LEFT JOIN pg_type t ON a.atttypid = t.oid,
LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation,
WHERE a.attrelid = '"snippet_files"'::regclass,
AND a.attnum > 0 AND NOT a.attisdropped,
ORDER BY a.attnum
Docker image version of 2019-06-01 00:16:15
Vladimir Avgustov commented
hi, did you run ./bin/setup
?
ils13 commented
Did run ./bin/setup
now.
./bin/setup
...
== Preparing database ==
Database 'postgres' already exists
rails aborted!
ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database.
If you are sure you want to continue, run the same command with the environment variable:
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
And with the env var, it wipes out the whole database instead of upgrading it (I do have a backup)
export DISABLE_DATABASE_ENVIRONMENT_CHECK=1
./bin/setup
...
== Preparing database ==
Database 'postgres' already exists
-- enable_extension("plpgsql")
-> 0.0235s
-- create_table("labels", {:force=>:cascade})
-> 0.1820s
-- create_table("snippet_files", {:force=>:cascade})
-> 0.1208s
-- create_table("snippets", {:force=>:cascade})
-> 0.1369s
-- create_table("users", {:force=>:cascade})
-> 0.1850s
ils13 commented
It's fixed by running ./bin/update
inside the container, and it migrated the old database to the new schema, and it all works again now.
Thanks a lot for Snibox and the quick support!