Skip to content
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

Doc fixes #90

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/OpenQA/modules/Schema/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ use IO::Dir;
use SQL::SplitStatement;
use Fcntl ':mode';

# after bumping the version ...
# - run script/initdb --prepare
# - run script/upgradedb --prepare
# - edit dbicdh/SQLite/upgrade/$old-$new/001-auto.sql and add missing triggers
# - optionally add migration script dbicdh/_common/upgrade/$old-$new/...
# after bumping the version please look at the instructions in the docs/Contributing.asciidoc file
# on what scripts should be run and how
our $VERSION = '15';

__PACKAGE__->load_namespaces;
Expand Down
23 changes: 19 additions & 4 deletions script/initdb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ use POSIX qw/getuid getgid setuid setgid/;
use openqa ();
use Schema::Schema;
use Getopt::Long;
use IO::Dir;

my $help=0;
my $prepare_init=0;
my $init_database=0;
my $force=0;

my $result = GetOptions(
"help" => \$help,
"prepare_init" => \$prepare_init,
"init_database" => \$init_database
"help" => \$help,
"prepare_init" => \$prepare_init,
"init_database" => \$init_database,
"force" => \$force
);

if (!$prepare_init and !$init_database) {
Expand All @@ -51,6 +54,7 @@ if ($help) {
print " and note those files should be commited to the source repo.\n";
print " --init_database : Use the generated deployment files created with --prepare_init\n";
print " to actually initialize a database.\n";
print " --force : Force overwriting existing data.\n";
print " --help : This help message.\n";
exit;
}
Expand Down Expand Up @@ -82,11 +86,22 @@ my $dh = DBIx::Class::DeploymentHandler->new(
script_directory => $script_directory,
databases => 'SQLite',
sql_translator_args => { add_drop_table => 1, producer_args => { sqlite_version => '3.7' } },
force_overwrite => 0,
force_overwrite => $force,
}
);

my $version = $dh->schema_version;

my %deploy_dir;
tie %deploy_dir, 'IO::Dir', "$script_directory/SQLite/deploy";

if ($prepare_init) {
if ( exists $deploy_dir{$version} and not $force) {
print "The deploy directory already contains the schema for the current version.\n";
print "Use the --force option if you want to overwrite the contents of the $script_directory/SQLite/upgrade/$version directory\n";
exit 1;
}

$dh->prepare_install;
}
if ($init_database) {
Expand Down
12 changes: 8 additions & 4 deletions script/upgradedb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ my $prepare_upgrades = 0;
my $upgrade_database = 0;
my $help = 0;
my $from_uninitialized_database = 0;
my $force = 0;

my $result = GetOptions(
"help" => \$help,
"from_uninitialized_database" => \$from_uninitialized_database,
"prepare_upgrades" => \$prepare_upgrades,
"upgrade_database" => \$upgrade_database
"upgrade_database" => \$upgrade_database,
"force" => \$force
);

if (!$prepare_upgrades and !$upgrade_database) {
Expand All @@ -57,6 +59,7 @@ if ($help) {
print " to actually upgrade a database.\n";
print " --from_uninitialized_database : Create and populate an existing database as if it was\n";
print " initialized with the initdb script.\n";
print " --force : Force overwriting existing data.\n";
print " --help : This help message.\n";
exit;
}
Expand All @@ -71,6 +74,7 @@ my $dh = DH->new(
script_directory => $script_directory,
databases => 'SQLite',
sql_translator_args => { add_drop_table => 0, producer_args => { sqlite_version => '3.7' } },
force_overwrite => $force,
}
);

Expand All @@ -89,9 +93,9 @@ my %deploy_dir;
tie %deploy_dir, 'IO::Dir', "$script_directory/SQLite/deploy";

if ($prepare_upgrades) {
if ( exists $upgrade_dir{$upgrade_directory} ) {
print "The current version $version already has upgrade data generated. Nothing to upgrade\n";
print "Remove the $script_directory/SQLite/upgrade/$upgrade_directory if you want to regenerate it\n";
if ( exists $upgrade_dir{$upgrade_directory} and not $force) {
print "The upgrade directory already contains files to upgrade to the current version ($version)\n";
print "Use the --force option if you want to overwrite the contents of the $script_directory/SQLite/upgrade/$upgrade_directory directory\n";
exit 1;
}

Expand Down