| 1 | |||
| 2 | package OpusVL::Preferences::Schema::Result::PrfPreference; | ||
| 3 | |||
| 4 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use MooseX::NonMoose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | extends 'DBIx::Class::Core'; | |
| 11 | |||
| 12 | 1 | __PACKAGE__->table("prf_preferences"); | |
| 13 | |||
| 14 | 1 | __PACKAGE__->add_columns | |
| 15 | ( | ||
| 16 | prf_preference_id => | ||
| 17 | { | ||
| 18 | data_type => "integer", | ||
| 19 | is_nullable => 0, | ||
| 20 | is_auto_increment => 1 | ||
| 21 | }, | ||
| 22 | |||
| 23 | prf_owner_id => | ||
| 24 | { | ||
| 25 | data_type => 'integer', | ||
| 26 | is_nullable => 0 | ||
| 27 | }, | ||
| 28 | |||
| 29 | prf_owner_type_id => | ||
| 30 | { | ||
| 31 | data_type => "integer", | ||
| 32 | is_nullable => 0, | ||
| 33 | }, | ||
| 34 | |||
| 35 | name => | ||
| 36 | { | ||
| 37 | data_type => 'varchar', | ||
| 38 | is_nullable => 0 | ||
| 39 | }, | ||
| 40 | |||
| 41 | value => | ||
| 42 | { | ||
| 43 | data_type => 'varchar', | ||
| 44 | is_nullable => 1 | ||
| 45 | }, | ||
| 46 | ); | ||
| 47 | |||
| 48 | 1 | __PACKAGE__->set_primary_key("prf_preference_id"); | |
| 49 | |||
| 50 | 1 | __PACKAGE__->add_unique_constraint([ qw/prf_preference_id prf_owner_type_id name/ ]); | |
| 51 | |||
| 52 | 1 | __PACKAGE__->belongs_to | |
| 53 | ( | ||
| 54 | prf_owner => 'OpusVL::Preferences::Schema::Result::PrfOwner', | ||
| 55 | { | ||
| 56 | 'foreign.prf_owner_id' => 'self.prf_owner_id', | ||
| 57 | 'foreign.prf_owner_type_id' => 'self.prf_owner_type_id' | ||
| 58 | } | ||
| 59 | ); | ||
| 60 | |||
| 61 | 1 | __PACKAGE__->might_have(unique_value => | |
| 62 | "OpusVL::Preferences::Schema::Result::CustomDataUniqueValues", | ||
| 63 | { | ||
| 64 | "foreign.prf_owner_type_id" => "self.prf_owner_type_id", | ||
| 65 | "foreign.name" => "self.name", | ||
| 66 | "foreign.value_id" => "self.prf_preference_id" | ||
| 67 | }, | ||
| 68 | { is_foreign_key_constraint => 0, cascade_delete => 1 }); | ||
| 69 | |||
| 70 | |||
| 71 | 1 | return 1; | |
| 72 | |||
| 73 | |||
| 74 | =head1 DESCRIPTION | ||
| 75 | |||
| 76 | This table actually contains the preference values; there is one row per field, per owner. | ||
| 77 | |||
| 78 | The owner_id column and owner_type_id column do the exact same thing as the | ||
| 79 | PrfOwner table, except here, they're a foreign key into the PrfOwner table. | ||
| 80 | |||
| 81 | That is to say, the prf_owner_id relates to an arbitrary table defined by the | ||
| 82 | host schema, and prf_owner_type_id refers to the prf_owner_types table, which | ||
| 83 | maps a number to the tables defined by the host schema. | ||
| 84 | |||
| 85 | For literally no reason whatsoever, the prf_owners table *also* encodes this | ||
| 86 | association, in a completely redundant fashion. | ||
| 87 | |||
| 88 | =head1 METHODS | ||
| 89 | |||
| 90 | =head1 ATTRIBUTES | ||
| 91 | |||
| 92 | =head2 prf_owner | ||
| 93 | |||
| 94 | =head2 prf_preference_id | ||
| 95 | |||
| 96 | =head2 prf_owner_id | ||
| 97 | |||
| 98 | =head2 prf_owner_type_id | ||
| 99 | |||
| 100 | =head2 name | ||
| 101 | |||
| 102 | =head2 value | ||
| 103 | |||
| 104 | |||
| 105 | =head1 LICENSE AND COPYRIGHT | ||
| 106 | |||
| 107 | Copyright 2012 OpusVL. | ||
| 108 | |||
| 109 | This software is licensed according to the "IP Assignment Schedule" provided with the development project. | ||
| 110 | |||
| 111 | =cut | ||