jjn1056 / DBIx-Class-Migration

Use DBIC::DeploymentHandler and DBIC::Fixtures together for a sane database versioning workflow
33 stars 41 forks source link

Strange error: #121

Closed KES777 closed 5 years ago

KES777 commented 5 years ago

If SQL::Translator::Producer::PostgreSQL has syntax error, the $(which dbic-migration) --force --schema_class HyperMouse::Schema --database PostgreSQL returns

Attribute (databases) does not pass the type constraint because: 
Unknown database type among (PostgreSQL) try:
GraphViz
YAML
Dumper
MySQL
DB2
PostgreSQL
Latex
TTSchema
JSON
HTML
ClassDBI
Diagram
POD
Sybase
XML
SQLite
Storable
DiaUml
Oracle
SQLServer
XML::SQLFairy
TT::Table
TT::Base
DBIx::Class::File
 at constructor DBIx::Class::Migration::Script::new (defined at /home/kes/work/projects/tucha/monkeyman/local/lib/perl5/DBIx/Class/Migration/Script.pm line 274) line 38
    DBIx::Class::Migration::Script::new('DBIx::Class::Migration::Script', 'ARGV', 'ARRAY(0x3bd32e8)', 'extra_argv', 'ARRAY(0x3fdf628)', 'usage', 'Getopt::Long::Descriptive::Usage=HASH(0x3dac710)', 'schema_class', 'HyperMouse::Schema', 'includes', 'ARRAY(0x3bd3af8)', 'databases', 'ARRAY(0x3bd3ab0)', 'force_overwrite', 1) called at /home/kes/work/projects/tucha/monkeyman/local/lib/perl5/MooseX/Getopt/Basic.pm line 115
    MooseX::Getopt::Basic::new_with_options('DBIx::Class::Migration::Script') called at /home/kes/work/projects/tucha/monkeyman/local/lib/perl5/DBIx/Class/Migration/Script.pm line 260
    DBIx::Class::Migration::Script::run_with_options('DBIx::Class::Migration::Script') called at /home/kes/work/projects/tucha/monkeyman/local/bin/dbic-migration line 4
Makefile:132: recipe for target 'dbprepare' failed
make: *** [dbprepare] Error 255

How to reproduce:

  1. Make syntax error into SQL::Translator::Producer::PostgreSQL module
  2. run $(which dbic-migration) --force --schema_class HyperMouse::Schema --database PostgreSQL
mohawk2 commented 5 years ago

You gave it a "database", which was invalid. It uses the loading of the producer class to determine validity. You made it invalid, so it told you it was invalid.

KES777 commented 5 years ago

It did not says it is invalid. It says "Unknown" and suggest to try parameter that I supply already: Unknown database type PostgreSQL ... try GraphViz ...PostgreSQL

would be much better if it shows failure error while loading PostgresSQL like Mojolicious does when can not load something: https://metacpan.org/release/Mojolicious/source/lib/Mojo/Loader.pm#L44 https://metacpan.org/release/Mojolicious/source/lib/Mojo/Loader.pm#L50