Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added update db script to make the model

  • Loading branch information...
commit 5f2c1d006d087a872a30dbef55c234869c48a090 1 parent cb7d420
@kthakore kthakore authored
View
43 lib/perlgamedev/Model/DB.pm
@@ -0,0 +1,43 @@
+package perlgamedev::Model::DB;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'perlgamedev::Schema',
+
+ connect_info => {
+ dsn => 'dbi:SQLite:dbname=test.db',
+ user => '',
+ password => '',
+ }
+);
+
+=head1 NAME
+
+perlgamedev::Model::DB - Catalyst DBIC Schema Model
+
+=head1 SYNOPSIS
+
+See L<perlgamedev>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<perlgamedev::Schema>
+
+=head1 GENERATED BY
+
+Catalyst::Helper::Model::DBIC::Schema - 0.43
+
+=head1 AUTHOR
+
+Kartik Thakore
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
View
23 lib/perlgamedev/Schema.pm
@@ -0,0 +1,23 @@
+package perlgamedev::Schema;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use Moose;
+use MooseX::NonMoose;
+use namespace::autoclean;
+extends 'DBIx::Class::Schema';
+
+__PACKAGE__->load_namespaces;
+
+
+# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-12-22 16:15:57
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:58R/0LTvt2JbiFlAs1kvpA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+__PACKAGE__->meta->make_immutable;
+1;
View
85 lib/perlgamedev/Schema/Result/Game.pm
@@ -0,0 +1,85 @@
+package perlgamedev::Schema::Result::Game;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use Moose;
+use MooseX::NonMoose;
+use namespace::autoclean;
+extends 'DBIx::Class::Core';
+
+__PACKAGE__->load_components("InflateColumn::DateTime");
+
+=head1 NAME
+
+perlgamedev::Schema::Result::Game
+
+=cut
+
+__PACKAGE__->table("Game");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: 'integer'
+ is_auto_increment: 1
+ is_nullable: 0
+
+=head2 name
+
+ data_type: 'text'
+ is_nullable: 1
+
+=head2 info
+
+ data_type: 'text'
+ is_nullable: 1
+
+=head2 image
+
+ data_type: 'text'
+ is_nullable: 1
+
+=cut
+
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
+ "name",
+ { data_type => "text", is_nullable => 1 },
+ "info",
+ { data_type => "text", is_nullable => 1 },
+ "image",
+ { data_type => "text", is_nullable => 1 },
+);
+__PACKAGE__->set_primary_key("id");
+
+=head1 RELATIONS
+
+=head2 games_tags
+
+Type: has_many
+
+Related object: L<perlgamedev::Schema::Result::GamesTag>
+
+=cut
+
+__PACKAGE__->has_many(
+ "games_tags",
+ "perlgamedev::Schema::Result::GamesTag",
+ { "foreign.gameid" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-12-22 16:15:57
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d5XCILOX8PqeQY4aopLzOA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+__PACKAGE__->meta->make_immutable;
+1;
View
94 lib/perlgamedev/Schema/Result/GamesTag.pm
@@ -0,0 +1,94 @@
+package perlgamedev::Schema::Result::GamesTag;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use Moose;
+use MooseX::NonMoose;
+use namespace::autoclean;
+extends 'DBIx::Class::Core';
+
+__PACKAGE__->load_components("InflateColumn::DateTime");
+
+=head1 NAME
+
+perlgamedev::Schema::Result::GamesTag
+
+=cut
+
+__PACKAGE__->table("GamesTag");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: 'int'
+ is_nullable: 0
+
+=head2 gameid
+
+ data_type: 'int'
+ is_foreign_key: 1
+ is_nullable: 0
+
+=head2 tagid
+
+ data_type: 'int'
+ is_foreign_key: 1
+ is_nullable: 0
+
+=cut
+
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "int", is_nullable => 0 },
+ "gameid",
+ { data_type => "int", is_foreign_key => 1, is_nullable => 0 },
+ "tagid",
+ { data_type => "int", is_foreign_key => 1, is_nullable => 0 },
+);
+__PACKAGE__->set_primary_key("id");
+
+=head1 RELATIONS
+
+=head2 tagid
+
+Type: belongs_to
+
+Related object: L<perlgamedev::Schema::Result::Tag>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "tagid",
+ "perlgamedev::Schema::Result::Tag",
+ { id => "tagid" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+=head2 gameid
+
+Type: belongs_to
+
+Related object: L<perlgamedev::Schema::Result::Game>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "gameid",
+ "perlgamedev::Schema::Result::Game",
+ { id => "gameid" },
+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-12-22 16:15:57
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2ZgqNdw3THVeYKlFF6bzyA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+__PACKAGE__->meta->make_immutable;
+1;
View
71 lib/perlgamedev/Schema/Result/Tag.pm
@@ -0,0 +1,71 @@
+package perlgamedev::Schema::Result::Tag;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use Moose;
+use MooseX::NonMoose;
+use namespace::autoclean;
+extends 'DBIx::Class::Core';
+
+__PACKAGE__->load_components("InflateColumn::DateTime");
+
+=head1 NAME
+
+perlgamedev::Schema::Result::Tag
+
+=cut
+
+__PACKAGE__->table("Tag");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: 'integer'
+ is_auto_increment: 1
+ is_nullable: 0
+
+=head2 name
+
+ data_type: 'text'
+ is_nullable: 1
+
+=cut
+
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
+ "name",
+ { data_type => "text", is_nullable => 1 },
+);
+__PACKAGE__->set_primary_key("id");
+
+=head1 RELATIONS
+
+=head2 games_tags
+
+Type: has_many
+
+Related object: L<perlgamedev::Schema::Result::GamesTag>
+
+=cut
+
+__PACKAGE__->has_many(
+ "games_tags",
+ "perlgamedev::Schema::Result::GamesTag",
+ { "foreign.tagid" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-12-22 16:15:57
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HY1DWIh6O25+HbBf+5SllA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+__PACKAGE__->meta->make_immutable;
+1;
View
10 script/update_db.pl
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+use DBI;
+
+unlink 'test.db';
+
+`sqlite3 test.db <schema.sql`;
+
+`script/perlgamedev_create.pl model DB DBIC::Schema perlgamedev::Schema create=static 'dbi:SQLite:dbname=test.db' '' ''`;
+
View
7 t/model_DB.t
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN { use_ok 'perlgamedev::Model::DB' }
+
+done_testing();
Please sign in to comment.
Something went wrong with that request. Please try again.