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

Easy db deployment #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ On a Debian system install the following packages:
```
geoip-bin libgeoip-dev geoip-database-contrib
```

# DB deployment instructions

* Install PostgreSQL
* Install PerlDancer with dependencies with ``cpanm .`` in a Git checkout directory
* psql create perldance
* ./bin/dh-install
* ./bin/dh-prepare-upgrade && ./bin/dh-upgrade
* Done!
21 changes: 21 additions & 0 deletions bin/dh-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env perl

use warnings;
use strict;

use Dancer qw/:script/;
use Dancer::Plugin::DBIC;
use DBIx::Class::DeploymentHandler;

my $schema = schema;
my $dh = DBIx::Class::DeploymentHandler->new(
{
schema => $schema,
databases => 'PostgreSQL',
sql_translator_args => { add_drop_table => 0 },
force_overwrite => 1,
}
);
$dh->prepare_version_storage_install;
$dh->prepare_install({ version => 1 });
$dh->install({ version => 1 });
3 changes: 2 additions & 1 deletion bin/dh-prepare-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ my $dh = DBIx::Class::DeploymentHandler->new(
{
schema => $schema,
databases => 'PostgreSQL',
sql_translator_args => { add_drop_table => 0 }
sql_translator_args => { add_drop_table => 0 },
force_overwrite => 1,
}
);
$dh->prepare_deploy;
Expand Down
5 changes: 3 additions & 2 deletions bin/dh-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ my $dh = DBIx::Class::DeploymentHandler->new(
{
schema => $schema,
databases => 'PostgreSQL',
sql_translator_args => { add_drop_table => 0 }
sql_translator_args => { add_drop_table => 0 },
force_overwrite => 1,
}
);
$dh->upgrade(
{
from_version => $dh->database_version,
to_version => $dh->schema_version
to_version => $dh->schema_version,
}
);
4 changes: 2 additions & 2 deletions lib/PerlDance/Schema/Upgrades/2016.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ sub upgrade {

# register organizators, gurus, speakers ...
my %attendees = (
'xsawyerx@cpan.org' => 1,
'xsawyerx@gmail.com' => 1,
'[email protected]' => 1,
'[email protected]' => 1,
'[email protected]' => 1,
#'[email protected]' => 1,
'[email protected]' => 1,
);

Expand Down
5 changes: 4 additions & 1 deletion lib/PerlDance/Schema/Upgrades/2016/Tickets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ sub upgrade {
my $self = shift;
my $schema = $self->schema;

my $conference = $schema->resultset('Conference')->find({
name => 'Perl Dancer Conference 2016',
});
# create new product(s)
my $tickets = $self->tickets;

Expand All @@ -48,7 +51,7 @@ sub upgrade {
my $conf = $schema->resultset('ConferenceTicket')->create(
{
sku => $t_prod->sku,
conferences_id => 2
conferences_id => $conference->id,
},
);

Expand Down
18 changes: 18 additions & 0 deletions sql/PostgreSQL/deploy/22/001-auto-__VERSION.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--
-- Created by SQL::Translator::Producer::PostgreSQL
-- Created on Thu Aug 4 00:25:30 2016
--
;
--
-- Table: dbix_class_deploymenthandler_versions
--
CREATE TABLE "dbix_class_deploymenthandler_versions" (
"id" serial NOT NULL,
"version" character varying(50) NOT NULL,
"ddl" text,
"upgrade_sql" text,
PRIMARY KEY ("id"),
CONSTRAINT "dbix_class_deploymenthandler_versions_version" UNIQUE ("version")
);

;
Loading