New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topic/producer postgresql batch alter table #44
Topic/producer postgresql batch alter table #44
Conversation
use SQL::Translator::Diff; | ||
|
||
eval "use DBD::Pg"; | ||
plan skip_all => "DBD::Pg required" if $@; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Test::SQL::Translator::maybe_plan() instead of hand-rolling this.
Good point - amazing how stupid I can be at times. |
foreach my $line (@diff) { | ||
$line =~ s/\n//g; | ||
next if $line =~ /^--/; | ||
lives_ok { $dbh->do($line) || die } "$line"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of lives_ok { … || die }
, set RaiseError
(preferrably) or just use ok( … )
.
2fd7173
to
78c6262
Compare
Initial test commit and later changes now merged into single commit. |
I think you forgot to push your single commit version. Second your "fail" mode dies out poorly:
|
78c6262
to
8bfb060
Compare
Changes and new test folded into a single commit. Fail should now die cleanly. |
I've reworked the tests a bit more and cleaned up the |
Had a look at people/ilmari/batch-alter branch + tested my ::Versioned::Inline toy against it and all seems good. I guess this PR can be closed? |
This initial version makes sure that drops on old table are handled before table rename and also fixes up rename_field/alter_field so that old field table name is changed to the name of the new table to prevent calls to alter_field from croaking. Test diffs are reordered but are otherwise unchanged.
I've added a test in a separate commit which uses Test::PostgreSQL to demonstrate one specific bug that this PR fixes (GH issue #40).