annotate Lib/IMPL/SQL/Schema/Traits.pm @ 269:dacfe7c0311a

SQL schema updated (unstable)
author sergey
date Thu, 24 Jan 2013 20:00:27 +0400
parents 4d0e1962161c
children 56364d0c4b4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
1 package IMPL::SQL::Schema::Traits;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
2 use strict;
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
3 use IMPL::_core::version;
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
4 use IMPL::Exception();
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
5
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
6 use parent qw(IMPL::Object);
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
7
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
8 # required for use with typeof operator
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
9 use IMPL::SQL::Schema::Constraint::PrimaryKey();
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
10 use IMPL::SQL::Schema::Constraint::Index();
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
11 use IMPL::SQL::Schema::Constraint::Unique();
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
12 use IMPL::SQL::Schema::Constraint::ForeignKey();
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
13
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
14 ###################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
15
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
16 package IMPL::SQL::Schema::Traits::Table;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
17 use base qw(IMPL::Object::Fields);
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
18
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
19 use fields qw(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
20 name
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21 columns
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 constraints
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23 options
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
24 );
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
25
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
26 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 my ($this,$table,$columns,$constraints,$options) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
29 $this->{name} = $table or die new IMPL::InvalidArgumentException(table => "A table name is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
30 $this->{columns} = $columns if defined $columns;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
31 $this->{constraints} = $constraints if defined $constraints;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32 $this->{options} = $options if defined $options;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
33 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
34
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
35 ###################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
36
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
37 package IMPL::SQL::Schema::Traits::Column;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
38 use base qw(IMPL::Object::Fields);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
39
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
40 use fields qw(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
41 name
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
42 type
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
43 isNullable
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
44 defaultValue
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
45 tag
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
46 );
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
47
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
48 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
49 my ($this, $name, $type, %args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
50
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
51 $this->{name} = $name or die new IMPL::InvalidArgumentException("name");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
52 $this->{type} = $type or die new IMPL::InvalidArgumentException("type");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
53 $this->{isNullable} = $args{isNullable} if exists $args{isNullable};
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
54 $this->{defaultValue} = $args{defaultValue} if exists $args{defaultValue};
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
55 $this->{tag} = $args{tag} if exists $args{tag};
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
56 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
57
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
58 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
59
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
60 package IMPL::SQL::Schema::Traits::Constraint;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
61 use base qw(IMPL::Object::Fields);
167
1f7a6d762394 SQL schema in progress
sourcer
parents: 165
diff changeset
62
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
63 use fields qw(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
64 name
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
65 columns
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
66 );
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
67
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
68 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
69 my ($this, $name, $columns) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
70
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
71 $this->{name} = $name;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
72 $this->{columns} = $columns; # list of columnNames
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
73 }
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
74
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
75 sub constraintClass {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
76 die new IMPL::NotImplementedException();
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
77 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
78
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
79 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
80
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
81 package IMPL::SQL::Schema::Traits::PrimaryKey;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
82
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
83 use base qw(IMPL::SQL::Schema::Traits::Constraint);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
84
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
85 __PACKAGE__->PassThroughArgs;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
86
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
87 use constant { constraintClass => typeof IMPL::SQL::Schema::Constraint::PrimaryKey };
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
88
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
89 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
90
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
91 package IMPL::SQL::Schema::Traits::Index;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
92
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
93 use base qw(IMPL::SQL::Schema::Traits::Constraint);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
94
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
95 __PACKAGE__->PassThroughArgs;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
96
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
97 use constant { constraintClass => typeof IMPL::SQL::Schema::Constraint::Index };
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
98
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
99 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
100
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
101 package IMPL::SQL::Schema::Traits::Unique;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
102
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
103 use base qw(IMPL::SQL::Schema::Traits::Constraint);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
104
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
105 __PACKAGE__->PassThroughArgs;
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
106
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
107 use constant { constraintClass => typeof IMPL::SQL::Schema::Constraint::Unique };
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
108
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
109 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
110
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
111 package IMPL::SQL::Schema::Traits::ForeignKey;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
112
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
113 use base qw(IMPL::SQL::Schema::Traits::Constraint);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
114 use fields qw(
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
115 foreignTable
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
116 foreignColumns
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
117 );
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
118
168
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
119 use constant { constraintClass => typeof IMPL::SQL::Schema::Constraint::ForeignKey };
6148f89bb7bf IMPL::SQL::Schema::Traits::Diff alfa version
sourcer
parents: 167
diff changeset
120
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
121 our %CTOR = (
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
122 'IMPL::SQL::Schema::Traits::Constraint' => sub { @_[0..1] }
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
123 );
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
124
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
125 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
126 my ($this,$foreignTable,$foreignColumns) = @_[0,3,4];
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
127
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
128 $this->{foreignTable} = $foreignTable;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
129 $this->{foreignColunms} = $foreignColumns;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
130 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
131
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
132
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
133 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
134
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
135 package IMPL::SQL::Schema::Traits::CreateTable;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
136
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
137 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
138 use IMPL::Class::Property;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
139 use IMPL::lang;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
140
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
141 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
142 public property table => prop_get | owner_set;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
143 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
144
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
145 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
146 my ($this,$table) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
147
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
148 die new IMPL::InvalidArgumentException("table", "An object of IMPL::SQL::Schema::Traits::Table type is required")
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
149 unless is $table, typeof IMPL::SQL::Schema::Traits::Table;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
150
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
151 $this->table($table);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
152 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
153
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
154 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
155 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
156
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
157 return 0 if ( $schema->GetTable( $this->table->{name} ) );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
158
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
159 $schema->AddTable($this->table);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
160 return 1;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
161 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
162
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
163 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
164
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
165 package IMPL::SQL::Schema::Traits::DropTable;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
166 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
167 use IMPL::Class::Property;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
168
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
169 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
170 public property tableName => prop_get | owner_set;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
171 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
172
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
173 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
174 my ($this,$tableName) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
175
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
176 $this->tableName($tableName) or die new IMPL::InvalidArgumentException("tableName is required");
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
177 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
178
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
179 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
180 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
181
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
182 return 0 if $schema->GetTable( $this->tableName );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
183
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
184 $schema->RemoveTable($this->tableName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
185
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
186 return 1;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
187 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
188
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
189 ##################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
190
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
191 package IMPL::SQL::Schema::Traits::RenameTable;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
192 use parent qw(-norequire IMPL::SQL::Schema::Traits);
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
193 use IMPL::Class::Property;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
194
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
195 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
196 public property tableName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
197 public property tableNewName => prop_get | owner_set;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
198 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
199
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
200 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
201 my ($this, $oldName, $newName) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
202
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
203 $this->tableName($oldName) or die new IMPL::InvalidArgumentException("A table name is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
204 $this->tableNewName($newName) or die new IMPL::InvalidArgumentException("A new table name is required");
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
205 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
206
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
207 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
208 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
209
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
210 return 0 if not $schema->GetTable($this->tableName) or $schema->GetTable($this->tableNewName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
211
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
212 $this->RenameTable($this->tableName, $this->tableNewName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
213
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
214 return 1;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
215 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
216
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
217 #################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
218
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
219 package IMPL::SQL::Schema::Traits::AlterTableAddColumn;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
220 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
221 use IMPL::Class::Property;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
222 use IMPL::lang;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
223
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
224 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
225 public property tableName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
226 public property column => prop_get | owner_set;
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
227 public property position => prop_get | owner_set;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
228 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
229
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
230 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
231 my ($this,$tableName,$column) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
232
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
233 $this->tableName($tableName) or die new IMPL::InvalidArgumentException("A table name is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
234
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
235 die new IMPL::InvalidArgumentException("A column should be a IMPL::SQL::Schema::Traits::Column object")
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
236 unless is $column, typeof IMPL::SQL::Schema::Traits::Column;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
237
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
238 $this->column($column);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
239 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
240
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
241 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
242 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
243
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
244 my $table = $schema->GetTable($this->tableName) or return 0;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
245
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
246 return 0 if $table->GetColumn( $this->column->{name} );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
247
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
248 $table->AddColumn($this->column);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
249
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
250 return 1;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
251 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
252
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
253 #################################################
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
254
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
255 package IMPL::SQL::Schema::Traits::AlterTableDropColumn;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
256 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
257 use IMPL::Class::Property;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
258
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
259 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
260 public property tableName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
261 public property columnName => prop_get | owner_set;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
262 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
263
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
264 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
265 my ($this,$table,$column) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
266
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
267 $this->tableName($table) or die new IMPL::InvalidArgumentException(tableName => "A table name should be specified");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
268 $this->columnName($column) or die new IMPL::InvalidArgumentException(columnName => "A column name should be specified");
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
269 }
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
270
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
271 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
272 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
273
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
274 local $@;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
275
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
276 return eval {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
277 $schema->GetTable($this->tableName)->RemoveColumn($this->columnName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
278 return 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
279 } || 0;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
280 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
281
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
282 #################################################
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
283
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
284 package IMPL::SQL::Schema::Traits::AlterTableChangeColumn;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
285 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
286 use IMPL::Class::Property;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
287
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
288 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
289 public property tableName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
290 public property columnName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
291 public property columnType => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
292 public property defaultValue => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
293 public property isNullable => prop_all;
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
294 public property position => prop_all;
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
295 public property options => prop_all; # hash diff format, (keys have a prefix '+' - add or update value, '-' remove value)
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
296 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
297
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
298 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
299 my ($this, $table,$column,%args) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
300
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
301 $this->tableName($table) or die new IMPL::InvalidArgumentException(tableName => "A table name is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
302 $this->columnName($column) or die new IMPL::InvalidArgumentException(columnName => "A column name is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
303
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
304 $this->$_($args{$_})
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
305 for (grep exists $args{$_}, qw(columnType defaultValue isNullable options));
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
306 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
307
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
308 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
309 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
310
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
311 local $@;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
312
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
313 return eval {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
314 my $column = $schema->GetTable($this->tableName)->GetColumn($this->columnName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
315 $column->SetType($this->columnType) if defined $this->columnType;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
316 $column->SetNullable($this->isNullable) if defined $this->isNullable;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
317 $column->SetDefaultValue($this->defaultValue) if defined $this->defaultValue;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
318 $column->SetOptions($this->options) if defined $this->options;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
319
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
320 return 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
321 } || 0;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
322 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
323
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
324 #################################################
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
325
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
326 package IMPL::SQL::Schema::Traits::AlterTableAddConstraint;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
327 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
328 use IMPL::Class::Property;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
329 use IMPL::lang;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
330
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
331 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
332 public property tableName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
333 public property constraint => prop_get | owner_set;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
334 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
335
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
336 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
337 my ($this,$table,$constraint) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
338
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
339 $this->tableName($table) or die new IMPL::InvalidArgumentException( tableName => "A table name is required");
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
340
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
341 die new IMPL::InvalidArgumentException(constaraint => "A valid IMPL::SQL::Schema::Traits::Constarint is required")
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
342 unless is $constraint, typeof IMPL::SQL::Schema::Traits::Constraint;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
343
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
344 $this->constraint($constraint);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
345 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
346
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
347 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
348 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
349
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
350 local $@;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
351
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
352 return eval {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
353 $schema->GetTable($this->tableName)->AddConstraint($this->constraint->constraintClass, $this->constraint);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
354 return 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
355 } || 0;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
356
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
357 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
358
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
359 #################################################
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
360
165
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
361 package IMPL::SQL::Schema::Traits::AlterTableDropConstraint;
76515373dac0 Added Class::Template,
wizard
parents: 164
diff changeset
362 use parent qw(-norequire IMPL::SQL::Schema::Traits);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
363 use IMPL::Class::Property;
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
364
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
365 BEGIN {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
366 public property tableName => prop_get | owner_set;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
367 public property constraintName => prop_get | owner_set;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
368 }
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
369
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
370 sub CTOR {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
371 my ($this,$table,$constraint) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
372
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
373 die new IMPL::InvalidArgumentException( tableName => "A table name is required" ) unless $table;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
374 die new IMPL::InvalidArgumentException( constraintName => "A constraint name is required" ) unless $constraint;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
375
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
376 $this->tableName($table);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
377 $this->constraintName($constraint);
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
378 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
379
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
380 sub apply {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
381 my ($this,$schema) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
382
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
383 my $table = $schema->GetTable($this->tableName) or return 0;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
384
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
385 return 0 unless $table->GetConstraint($this->constraintName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
386
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
387 $table->RemoveConstraint($this->constraintName);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
388 return 1;
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
389 }
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
390
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
391
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 44
diff changeset
392 1;
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
393
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
394 __END__
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
395
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
396 =pod
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
397
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
398 =head1 NAME
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
399
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
400 C<IMPL::SQL::Traits> - Операции над объектками SQL схемы.
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
401
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
402 =head1 DESCRIPTION
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
403
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
404 Изменения схемы могу быть представлены в виде последовательности примитивных операций.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
405 Правила выполнения последовательности примитывных действий могут варьироваться
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
406 в зависимости от процессора, который их выполняет. Например C<IMPL::SQL::Schema::Traits::Processor>.
163
6ce1f052b90a temp commit
wizard
parents: 49
diff changeset
407
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
408 Данные, которые содержаться в примитивных операциях не могут существовать независимо от схемы.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
409
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
410 =head1 OPERATIONS
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
411
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
412 =head2 General
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
413
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
414 Методы обще для всех примитивных операций.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
415
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
416 =head3 C<apply($schema)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
417
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
418 Пытается приминить операцию к указанной схеме.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
419
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
420 Возвращаемое значение:
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
421
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
422 =over
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
423
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
424 =item C<true>
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
425
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
426 Операция успешно применена к схеме.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
427
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
428 =item C<false>
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
429
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
430 Операция не может быть применена к схеме.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
431
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
432 =back
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
433
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
434 =head2 Primitive operations
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
435
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
436 =head3 C<IMPL::SQL::Schema::Traits::CreateTable>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
437
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
438 Создает таблицу
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
439
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
440 =head4 C<CTOR($table)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
441
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
442 =head4 C<[get]table>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
443
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
444 C<IMPL::SQL::Schema::Traits::Table> - описание создаваемой таблицы
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
445
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
446 =head3 C<IMPL::SQL::Schema::Traits::DropTable>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
447
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
448 Удалает таблицу по имени
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
449
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
450 =head4 C<CTOR($tableName)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
451
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
452 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
453
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
454 Имя удаляемой таблицы
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
455
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
456 =head3 C<IMPL::SQL::Schema::Traits::RenameTable>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
457
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
458 =head4 C<CTOR($tableName,$tableNewName)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
459
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
460 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
461
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
462 Имя таблицы, которую требуется переименовать
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
463
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
464 =head4 C<[get]tableNewName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
465
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
466 Новое имя таблицы
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
467
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
468 =head3 C<IMPL::SQL::Schema::Traits::AlterTableAddColumn>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
469
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
470 Добавляет столбец в таблицу
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
471
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
472 =head4 C<CTOR($tableName,$column,$position)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
473
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
474 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
475
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
476 Имя таблицы в которую нужно добавить столбец
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
477
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
478 =head4 C<[get]column>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
479
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
480 C<IMPL::SQL::Schema::Traits::Column> - описание столбца который нужно добавить
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
481
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
482 =head4 C<[get]position>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
483
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
484 Позиция на которую нужно вставить столбец
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
485
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
486 =head3 C<IMPL::SQL::Schema::Traits::AlterTableDropColumn>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
487
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
488 Удаляет столбец из таблицы
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
489
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
490 =head4 C<CTOR($tableName,$columnName)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
491
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
492 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
493
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
494 Имя таблицы в которой нужно удалить столбец
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
495
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
496 =head4 C<[get]columnName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
497
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
498 Имя столбца для удаления
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
499
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
500 =head3 C<IMPL::SQL::Schema::Traits::AlterTableChangeColumn>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
501
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
502 Меняет описание столбца
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
503
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
504 =head4 C<CTOR($tableName,$columnName,%args)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
505
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
506 C<%args> - хеш, ключами которого являются оставшиеся свойства создаваемого объекта.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
507
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
508 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
509
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
510 Имя таблицы в которой находится столбец.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
511
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
512 =head4 C<[get]columnName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
513
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
514 Имя столбца для изменения
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
515
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
516 =head4 C<[get]columnType>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
517
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
518 Новый тип столбца. Не задан, если тип не меняется
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
519
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
520 =head4 C<[get]defaultValue>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
521
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
522 Значение по умолчанию. Не задано, если не меняется
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
523
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
524 =head4 C<[get]isNullable>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
525
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
526 Может ли столбец содержать C<NULL>. Не задано, если не меняется.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
527
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
528 =head4 C<[get]options>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
529
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
530 Хеш опций, не задан, если опции не меняются. Данный хеш содержит разничу между
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
531 старыми и новыми значениями свойства C<tag> столбца.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
532
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
533
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
534 =head3 C<IMPL::SQL::Schema::Traits::AlterTableAddConstraint>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
535
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
536 Базовый класс для операций по добавлению ограничений
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
537
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
538 =head4 C<CTOR($tableName,$constraint)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
539
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
540 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
541
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
542 Имя таблицы в которую добавляется ограничение.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
543
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
544 =head4 C<[get]constraint>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
545
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
546 C<IMPL::SQL::Schema::Traits::Constraint> - описние ограничения, которое нужно добавить.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
547
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
548 =head3 C<IMPL::SQL::Schema::Traits::AlterTableDropConstraint>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
549
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
550 Удаляет ограничение на таблицу
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
551
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
552 =head4 C<CTOR($tableName,$constraintName)>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
553
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
554 =head4 C<[get]tableName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
555
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
556 Имя таблицы в которой требуется удалить ограничение.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
557
269
dacfe7c0311a SQL schema updated (unstable)
sergey
parents: 194
diff changeset
558 =head4 C<[get]constraintName>
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
559
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
560 Имя ограничения для удаления.
164
eb3e9861a761 SQL traits in progress
wizard
parents: 163
diff changeset
561
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 169
diff changeset
562 =cut