warn if no tables found in helper
Rafael Kitover [Wed, 27 Jul 2011 03:51:16 +0000 (23:51 -0400)]
After dumping the schema in the helper, loads the dumped Schema, checks
->sources and if empty prints a warning with a suggestion to specify
db_schema.

lib/Catalyst/Helper/Model/DBIC/Schema.pm

index 16e8634..b947be4 100644 (file)
@@ -596,6 +596,19 @@ sub _gen_static_schema {
         $self->loader_args,
         [$self->connect_info]
     );
+
+    require lib;
+    lib->import($schema_dir);
+
+    Class::MOP::load_class($self->schema_class);
+
+    my @sources = $self->schema_class->sources;
+
+    if (not @sources) {
+        warn <<'EOF';
+WARNING: No tables found, did you forget to specify db_schema?
+EOF
+    }
 }
 
 sub _gen_model {