bduggan / Module-Build-Database

Module::Build::Database -- manage your database, Module::Build style
1 stars 2 forks source link

"error with existing schema" difficult to debug because schema is in temp file #10

Closed plicease closed 10 years ago

plicease commented 10 years ago

During ./Build dbfakeinstall when there is an error reloading the production schema into the temp database I get a helpful message:

applying base.sql
psql:/osips/archive/tmp/pncEOErxcl:10584: ERROR:  data type timestamp without time zone has no default operator class for access method "gist"
HINT:  You must specify an operator class for the index or define a default operator class for the data type.
Error with '/usr/local/bin/psql -q -v'ON_ERROR_STOP=1' -f /osips/archive/tmp/pncEOErxcl sipsdb' : 768 768

but the schema is stored in a temporary file, so it is hard to tell where the actual problem is. I could probably dump the schema is pg_dump, but I think it would be a nice improvement to:

  1. save the schema to a file in the dist root
  2. execute the schema on the temp db
  3. if successful remove the schema
  4. if not successful keep it around

That way if there is a failure on that step I can immediately open the dump to the appropriate line and if there isn't the schema sql isn't cluttering up the dist root.

The schema dump would also be added to MB cleanup so ./Build clean would remove it as well.

I can do the work, but wanted to document the issue here in case you had any concerns or alternative suggestions.

bduggan commented 10 years ago

That sounds like a good improvement to diagnose problems with a dump + restore. Just keeping all the temporary files around based on a command line option or environment variable would be fine too. ($File::Temp::KEEP_ALL = 1 if $ENV{MBD_KEEP_ALL_TEMP_FILES...?)