Skip to content

Commit

Permalink
Added Year and Form tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Sep 7, 2014
1 parent 7d3f58a commit 917203a
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 3 deletions.
108 changes: 108 additions & 0 deletions Kinza/lib/Kinza/Schema/Result/Form.pm
@@ -0,0 +1,108 @@
use utf8;
package Kinza::Schema::Result::Form;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
Kinza::Schema::Result::Form
=cut

use strict;
use warnings;

use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::TimeStamp>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp");

=head1 TABLE: C<form>
=cut

__PACKAGE__->table("form");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 1
size: 255
=head2 year_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"name",
{ data_type => "varchar", is_nullable => 1, size => 255 },
"year_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 year
Type: belongs_to
Related object: L<Kinza::Schema::Result::Year>
=cut

__PACKAGE__->belongs_to(
"year",
"Kinza::Schema::Result::Year",
{ id => "year_id" },
{ is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" },
);


# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-09-07 16:18:05
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EMHLaKP8SKqzMLixsT0NGg


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;
11 changes: 9 additions & 2 deletions Kinza/lib/Kinza/Schema/Result/Student.pm
Expand Up @@ -64,6 +64,11 @@ __PACKAGE__->table("student");
is_nullable: 0
size: 255
=head2 form_id
data_type: 'integer'
is_nullable: 1
=head2 verify
data_type: 'varchar'
Expand All @@ -81,6 +86,8 @@ __PACKAGE__->add_columns(
{ data_type => "varchar", is_nullable => 0, size => 255 },
"password",
{ data_type => "varchar", is_nullable => 0, size => 255 },
"form_id",
{ data_type => "integer", is_nullable => 1 },
"verify",
{ data_type => "varchar", is_nullable => 1, size => 255 },
);
Expand Down Expand Up @@ -130,8 +137,8 @@ __PACKAGE__->has_many(
);


# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-09-03 19:32:04
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:83EZioIV2OOEpR1u6nAfyw
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-09-07 16:26:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fWMkkeXm2GOsOwXsmSBr9g

sub sorted_attendances {
my $self = shift;
Expand Down
100 changes: 100 additions & 0 deletions Kinza/lib/Kinza/Schema/Result/Year.pm
@@ -0,0 +1,100 @@
use utf8;
package Kinza::Schema::Result::Year;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
Kinza::Schema::Result::Year
=cut

use strict;
use warnings;

use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;
extends 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::TimeStamp>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp");

=head1 TABLE: C<year>
=cut

__PACKAGE__->table("year");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 1
size: 255
=cut

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"name",
{ data_type => "varchar", is_nullable => 1, size => 255 },
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 forms
Type: has_many
Related object: L<Kinza::Schema::Result::Form>
=cut

__PACKAGE__->has_many(
"forms",
"Kinza::Schema::Result::Form",
{ "foreign.year_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);


# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-09-07 16:18:05
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hAolxMnPEFonrAaw4rktsg


# You can replace this text with custom code or comments, and it will be preserved on regeneration
__PACKAGE__->meta->make_immutable;
1;
24 changes: 24 additions & 0 deletions db_schema/Form.tsv
@@ -0,0 +1,24 @@
name year_id
Upper 3F 1
Upper 3K 1
Upper 3S 1
Lower 4F 2
Lower 4K 2
Lower 4S 2
Upper 4F 3
Upper 4K 3
Upper 4S 3
Lower 5F 4
Lower 5K 4
Lower 5S 4
Upper 5F 5
Upper 5K 5
Upper 5S 5
Lower 6P 6
Lower 6Q 6
Lower 6R 6
Lower 6S 6
Upper 6A 7
Upper 6B 7
Upper 6C 7
Upper 6D 7
8 changes: 8 additions & 0 deletions db_schema/Year.tsv
@@ -0,0 +1,8 @@
name
Upper 3
Lower 4
Upper 4
Lower 5
Upper 5
Lower 6
Upper 6
16 changes: 15 additions & 1 deletion db_schema/kinza.sql
@@ -1,3 +1,15 @@
CREATE TABLE year (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255)
) ENGINE=InnoDB;

CREATE TABLE form (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name varchar(255),
year_id INTEGER NOT NULL,
FOREIGN KEY (year_id) REFERENCES year(id)
) ENGINE=InnoDB;

CREATE TABLE course (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
Expand All @@ -19,7 +31,9 @@ id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
verify VARCHAR(255)
form_id INTEGER,
verify VARCHAR(255),
FOREIGN KEY (form_id) REFERENCES form(id)
) ENGINE=InnoDB;

CREATE TABLE presentation (
Expand Down

0 comments on commit 917203a

Please sign in to comment.