Skip to content

Commit

Permalink
Various DB changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Apr 8, 2012
1 parent cac5d21 commit deca994
Show file tree
Hide file tree
Showing 6 changed files with 388 additions and 41 deletions.
60 changes: 42 additions & 18 deletions Shrtr/lib/Shrtr/Schema/Result/Click.pm
Expand Up @@ -23,13 +23,17 @@ __PACKAGE__->table("click");

=head1 ACCESSORS
=head2 code
=head2 id
data_type: 'char'
default_value: (empty string)
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 url
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
size: 10
=head2 ts
Expand All @@ -38,30 +42,50 @@ __PACKAGE__->table("click");
default_value: current_timestamp
is_nullable: 0
=head2 referrer
data_type: 'varchar'
is_nullable: 1
size: 200
=head2 user_agent
data_type: 'varchar'
is_nullable: 1
size: 200
=head2 ip_address
data_type: 'varchar'
is_nullable: 1
size: 15
=cut

__PACKAGE__->add_columns(
"code",
{
data_type => "char",
default_value => "",
is_foreign_key => 1,
is_nullable => 0,
size => 10,
},
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"url",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"ts",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
default_value => \"current_timestamp",
is_nullable => 0,
},
"referrer",
{ data_type => "varchar", is_nullable => 1, size => 200 },
"user_agent",
{ data_type => "varchar", is_nullable => 1, size => 200 },
"ip_address",
{ data_type => "varchar", is_nullable => 1, size => 15 },
);
__PACKAGE__->set_primary_key("code", "ts");
__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 code
=head2 url
Type: belongs_to
Expand All @@ -70,15 +94,15 @@ Related object: L<Shrtr::Schema::Result::Url>
=cut

__PACKAGE__->belongs_to(
"code",
"url",
"Shrtr::Schema::Result::Url",
{ code => "code" },
{ id => "url" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);


# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-07 18:07:23
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wiVhL4PQO+reBzw8mhZ2xA
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-08 16:55:07
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QKX3HxrPBWEZWIqX7fmKqQ


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
57 changes: 44 additions & 13 deletions Shrtr/lib/Shrtr/Schema/Result/Url.pm
Expand Up @@ -23,33 +23,49 @@ __PACKAGE__->table("url");

=head1 ACCESSORS
=head2 code
=head2 id
data_type: 'char'
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
size: 10
=head2 code
data_type: 'varchar'
is_nullable: 1
size: 200
=head2 url
data_type: 'text'
is_nullable: 1
=head2 clicks
=head2 ts
data_type: 'integer'
is_nullable: 1
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: current_timestamp
is_nullable: 0
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"code",
{ data_type => "char", is_nullable => 0, size => 10 },
{ data_type => "varchar", is_nullable => 1, size => 200 },
"url",
{ data_type => "text", is_nullable => 1 },
"clicks",
{ data_type => "integer", is_nullable => 1 },
"ts",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
default_value => \"current_timestamp",
is_nullable => 0,
},
);
__PACKAGE__->set_primary_key("code");
__PACKAGE__->set_primary_key("id");
__PACKAGE__->add_unique_constraint("code", ["code"]);

=head1 RELATIONS
Expand All @@ -64,13 +80,28 @@ Related object: L<Shrtr::Schema::Result::Click>
__PACKAGE__->has_many(
"clicks",
"Shrtr::Schema::Result::Click",
{ "foreign.code" => "self.code" },
{ "foreign.url" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 user_urls
Type: has_many
Related object: L<Shrtr::Schema::Result::UserUrl>
=cut

__PACKAGE__->has_many(
"user_urls",
"Shrtr::Schema::Result::UserUrl",
{ "foreign.url" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);


# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-07 18:07:23
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:l7R0kmpTDN1yZj4gR4dfWA
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-08 16:55:07
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FoXnNJ92XRZorgk006qkXQ


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
87 changes: 87 additions & 0 deletions Shrtr/lib/Shrtr/Schema/Result/User.pm
@@ -0,0 +1,87 @@
package Shrtr::Schema::Result::User;

# 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
Shrtr::Schema::Result::User
=cut

__PACKAGE__->table("user");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 username
data_type: 'varchar'
is_nullable: 0
size: 20
=head2 email
data_type: 'varchar'
is_nullable: 0
size: 100
=head2 password
data_type: 'varchar'
is_nullable: 0
size: 32
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"username",
{ data_type => "varchar", is_nullable => 0, size => 20 },
"email",
{ data_type => "varchar", is_nullable => 0, size => 100 },
"password",
{ data_type => "varchar", is_nullable => 0, size => 32 },
);
__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 user_urls
Type: has_many
Related object: L<Shrtr::Schema::Result::UserUrl>
=cut

__PACKAGE__->has_many(
"user_urls",
"Shrtr::Schema::Result::UserUrl",
{ "foreign.user" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);


# Created by DBIx::Class::Schema::Loader v0.07010 @ 2012-04-08 16:55:07
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7SBEwAu9bk3x1S2vRK63Zg


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;

0 comments on commit deca994

Please sign in to comment.