add PrimaryKey and ForeignKey classes
Justin Hunter [Sat, 11 Jul 2009 19:28:31 +0000 (12:28 -0700)]
lib/SQL/Translator/Object/ForeignKey.pm [new file with mode: 0644]
lib/SQL/Translator/Object/PrimaryKey.pm [new file with mode: 0644]
lib/SQL/Translator/Types.pm

diff --git a/lib/SQL/Translator/Object/ForeignKey.pm b/lib/SQL/Translator/Object/ForeignKey.pm
new file mode 100644 (file)
index 0000000..6f0f19f
--- /dev/null
@@ -0,0 +1,16 @@
+package SQL::Translator::Object::ForeignKey;
+use Moose;
+use SQL::Translator::Types qw(Index PrimaryKey);
+extends 'SQL::Translator::Object::Constraint';
+
+has '+type' => (
+    default => 'FOREIGN_KEY',
+);
+
+has 'references' => (
+    isa => PrimaryKey | Index,
+    is => 'rw',
+    required => 1,
+);
+
+1;
diff --git a/lib/SQL/Translator/Object/PrimaryKey.pm b/lib/SQL/Translator/Object/PrimaryKey.pm
new file mode 100644 (file)
index 0000000..8a1b16c
--- /dev/null
@@ -0,0 +1,9 @@
+package SQL::Translator::Object::PrimaryKey;
+use Moose;
+extends 'SQL::Translator::Object::Index';
+
+has '+type' => (
+    default => 'PRIMARY_KEY',
+);
+
+1;
index 1693303..ed89687 100644 (file)
@@ -1,10 +1,12 @@
 package SQL::Translator::Types;
 use MooseX::Types::Moose qw(ArrayRef CodeRef Str);
-use MooseX::Types -declare, [qw(Column Constraint Index Procedure Schema Sequence Table Trigger View DBIHandle)];
+use MooseX::Types -declare, [qw(Column Constraint ForeignKey Index PrimaryKey Procedure Schema Sequence Table Trigger View DBIHandle)];
 
 class_type Column, { class => 'SQL::Translator::Object::Column' };
 class_type Constraint, { class => 'SQL::Translator::Object::Constraint' };
+class_type ForeignKey, { class => 'SQL::Translator::Object::ForeignKey' };
 class_type Index, { class => 'SQL::Translator::Object::Index' };
+class_type PrimaryKey, { class => 'SQL::Translator::Object::PrimaryKey' };
 class_type Procedure, { class => 'SQL::Translator::Object::Procedure' };
 class_type Schema, { class => 'SQL::Translator::Object::Schema' };
 class_type Sequence, { class=> 'SQL::Translator::Object::Sequence' };