| 1 | package Mojolicious::Plugin::Migration::Sqitch::Command::schema_initdb 0.01; | ||
| 2 | use v5.26; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | =pod | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | Usage: <APP> schema-initdb [--reset] | ||
| 10 | |||
| 11 | Options: | ||
| 12 | --reset Drop database and re-create | ||
| 13 | |||
| 14 | =cut | ||
| 15 | |||
| 16 | use Mojo::Base 'Mojolicious::Command'; | ||
| 17 | use Getopt::Long qw(GetOptionsFromArray :config pass_through); | ||
| 18 | |||
| 19 | use experimental qw(signatures); | ||
| 20 | |||
| 21 | has description => 'Perform database schema initialization'; | ||
| 22 | has usage => sub ($self) {$self->extract_usage}; | ||
| 23 | |||
| 24 | sub run($self, @args) { | ||
| 25 | GetOptionsFromArray(\@args, reset => \my $reset,); | ||
| 26 | if ($reset) { | ||
| 27 | print "This will result in all data being deleted from the database. Are you sure you want to continue? [yN] "; | ||
| 28 | my $response = <STDIN>; | ||
| 29 | chomp($response); | ||
| 30 | die("Aborted\n") unless ($response =~ /^y(es|eah)?$/i); | ||
| 31 | } | ||
| 32 | $self->app->run_schema_initialization({reset => $reset}); | ||
| 33 | } | ||
| 34 | |||
| 35 | =pod | ||
| 36 | |||
| 37 | =head1 AUTHOR | ||
| 38 | |||
| 39 | Mark Tyrrell C<< <mark@tyrrminal.dev> >> | ||
| 40 | |||
| 41 | =head1 LICENSE | ||
| 42 | |||
| 43 | Copyright (c) 2024 Mark Tyrrell | ||
| 44 | |||
| 45 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 46 | of this software and associated documentation files (the "Software"), to deal | ||
| 47 | in the Software without restriction, including without limitation the rights | ||
| 48 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 49 | copies of the Software, and to permit persons to whom the Software is | ||
| 50 | furnished to do so, subject to the following conditions: | ||
| 51 | |||
| 52 | The above copyright notice and this permission notice shall be included in all | ||
| 53 | copies or substantial portions of the Software. | ||
| 54 | |||
| 55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 56 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 57 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 58 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 59 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 60 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 61 | SOFTWARE. | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | 1; | ||
| 66 | |||
| 67 | __END__ |