frioux / DBIx-Class-DeploymentHandler

https://metacpan.org/pod/DBIx::Class::DeploymentHandler
20 stars 25 forks source link

Can't find source for ... #62

Closed davewood closed 6 years ago

davewood commented 6 years ago

DBIx::Class::DeploymentHandler version 999 required--this is only version 0.002219. This is perl 5, version 22, subversion 2 (v5.22.2)

I am maintaining an old project where I stupidly used "user" as a table name. this makes things unnecessarily painful because its a reserved word. but i have to stick with it.

I manually quoted the table name in ...

#db_upgrades/PostgreSQL/upgrade/57-58/001-auto.sql
DROP TABLE "user" CASCADE;

but now I get this error, possibly not related to the quoting stuff. i follow the same procedure as in the past but something appears to have changed

david@nbdt:~/dev/EPPlication$ ./script/database.pl --cmd upgrade
NOTICE:  drop cascades to constraint user_role_fk_role_id on table user_role
NOTICE:  drop cascades to constraint test_tag_fk_tag_id on table test_tag
NOTICE:  drop cascades to 4 other objects
DETAIL:  drop cascades to constraint step_fk_test_id on table step
drop cascades to constraint job_fk_config_id on table job
drop cascades to constraint job_fk_test_id on table job
drop cascades to constraint test_tag_fk_test_id on table test_tag
NOTICE:  drop cascades to 2 other objects
DETAIL:  drop cascades to constraint job_fk_user_id on table job
drop cascades to constraint user_role_fk_user_id on table user_role
NOTICE:  drop cascades to constraint step_result_fk_job_id on table step_result
failed to run Perl in /home/david/dev/EPPlication/script/../lib/EPPlication/Util/../../../db_upgrades/_common/upgrade/57-58/002_add_filter_param.pl: DBIx::Class::Schema::source(): Can't find source for Step at /home/david/dev/EPPlication/script/../lib/EPPlication/Util/../../../db_upgrades/_common/upgrade/57-58/002_add_filter_param.pl line 16

You are seeing this error because the DBIx::Class::ResultSource in your
migration script called "Step" is not part of the schema that ::Schema::Loader
has inferred from your existing database.

To help you debug this issue, here's a list of the actual sources that the
schema available to your migration knows about:

 DbixClassDeploymenthandlerVersion

DBIx::Class::Storage::TxnScopeGuard::DESTROY(): A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back. at /home/david/perl5/perlbrew/perls/perl-5.22.2/lib/site_perl/5.22.2/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm line 321
DBIx::Class::Storage::TxnScopeGuard::DESTROY(): A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back. at /home/david/perl5/perlbrew/perls/perl-5.22.2/lib/site_perl/5.22.2/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator.pm line 321

my upgrade script

#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use EPPlication::Util::SchemaUpgradeHelper qw/ get_params set_params add_param change_param /;

use
  DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::ScriptHelpers
  'schema_from_schema_loader';

schema_from_schema_loader(
    { naming => { ALL => 'v8', force_ascii => 1 } },
    sub {
        my ( $schema, $versions ) = @_;

        my $step_rs = $schema->resultset('Step')->search( { type => 'PrintVars' } );
        say "Add filter param.";

        while ( my $step = $step_rs->next ) {
            say "Upgrade for step " . $step->id;
            my $params = get_params($step);
            add_param( $params, 'filter', '' );
            set_params($step, $params);
        }
    }
);
davewood commented 6 years ago

the first part (quoting issue) was resolved in version 0.002222

...

and so was the second issue (couldnt find source for)

i will leave it to you to close the issue. :)

cheers david

frioux commented 6 years ago

Haha, ok!