| 1 | package Mojolicious::Plugin::Migration::Sqitch::Command::schema_migrate 0.01; | ||
| 2 | use v5.26; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | =pod | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | Usage: <APP> schema-migrate [args] | ||
| 10 | |||
| 11 | Options: | ||
| 12 | args passed to sqitch | ||
| 13 | (defaults to "deploy" if omitted) | ||
| 14 | |||
| 15 | =cut | ||
| 16 | |||
| 17 | use Mojo::Base 'Mojolicious::Command'; | ||
| 18 | |||
| 19 | use experimental qw(signatures); | ||
| 20 | |||
| 21 | has description => 'Perform database schema migrations'; | ||
| 22 | has usage => sub ($self) {$self->extract_usage}; | ||
| 23 | |||
| 24 | sub run($self, @args) { | ||
| 25 | unshift(@args, 'deploy') unless (@args); | ||
| 26 | die("You must specify a sqitch subcommand (e.g., deploy or revert)\n") if (@args && !grep {/^[^-]/} @args); | ||
| 27 | my $v = $self->app->run_schema_migration(join(q{ }, @args)); | ||
| 28 | warn "an error occurred: $v\n" and exit $v if ($v); | ||
| 29 | } | ||
| 30 | |||
| 31 | =pod | ||
| 32 | |||
| 33 | =head1 AUTHOR | ||
| 34 | |||
| 35 | Mark Tyrrell C<< <mark@tyrrminal.dev> >> | ||
| 36 | |||
| 37 | =head1 LICENSE | ||
| 38 | |||
| 39 | Copyright (c) 2024 Mark Tyrrell | ||
| 40 | |||
| 41 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 42 | of this software and associated documentation files (the "Software"), to deal | ||
| 43 | in the Software without restriction, including without limitation the rights | ||
| 44 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 45 | copies of the Software, and to permit persons to whom the Software is | ||
| 46 | furnished to do so, subject to the following conditions: | ||
| 47 | |||
| 48 | The above copyright notice and this permission notice shall be included in all | ||
| 49 | copies or substantial portions of the Software. | ||
| 50 | |||
| 51 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 52 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 53 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 54 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 55 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 56 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 57 | SOFTWARE. | ||
| 58 | |||
| 59 | =cut | ||
| 60 | |||
| 61 | 1; | ||
| 62 | |||
| 63 | __END__ |