From: Justin Hunter Date: Thu, 28 May 2009 16:36:50 +0000 (-0700) Subject: initial X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c50513510a3498997d753b0e9c1fe36955e5528b;p=dbsrgits%2FSQL-Translator-2.0-ish.git initial --- diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm new file mode 100644 index 0000000..78a0041 --- /dev/null +++ b/lib/SQL/Translator.pm @@ -0,0 +1,3 @@ +package SQL::Translator; + +1; diff --git a/lib/SQL/Translator/Object.pm b/lib/SQL/Translator/Object.pm new file mode 100644 index 0000000..8e80f8b --- /dev/null +++ b/lib/SQL/Translator/Object.pm @@ -0,0 +1,4 @@ +package SQL::Translator::Object; +use base 'SQL::Translator'; + +1; diff --git a/lib/SQL/Translator/Object/Column.pm b/lib/SQL/Translator/Object/Column.pm new file mode 100644 index 0000000..dcb4cb3 --- /dev/null +++ b/lib/SQL/Translator/Object/Column.pm @@ -0,0 +1,11 @@ +package SQL::Translator::Object::Column; +use Moose; + +has 'name' => (is => 'ro', isa => 'Str', required => 1); +has 'type' => (is => 'ro', isa => 'Str', required => 1); +has 'size' => (is => 'ro', isa => 'Int', required => 1); +has 'nullable' => (is => 'ro', isa => 'Bool', required => 1, default => 1); +has 'default' => (is => 'ro', isa => 'Str', required => 0); +has 'trigger' => (is => 'ro', isa => 'SQL::Translator::Object::Trigger', required => 0); + +1; diff --git a/lib/SQL/Translator/Object/Constraint.pm b/lib/SQL/Translator/Object/Constraint.pm new file mode 100644 index 0000000..a604611 --- /dev/null +++ b/lib/SQL/Translator/Object/Constraint.pm @@ -0,0 +1,8 @@ +package SQL::Translator::Object::Constraint; +use Moose; + +has 'name' => (is => 'ro', isa => 'Str', required => 1); +has 'columns' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Column]', required => 1); +has 'type' => (is => 'ro', isa => 'Str', required => 1); + +1; diff --git a/lib/SQL/Translator/Object/Index.pm b/lib/SQL/Translator/Object/Index.pm new file mode 100644 index 0000000..64d3554 --- /dev/null +++ b/lib/SQL/Translator/Object/Index.pm @@ -0,0 +1,8 @@ +package SQL::Translator::Object::Index; +use Moose; + +has 'name' => (is => 'ro', isa => 'Str', required => 1); +has 'columns' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Column]', required => 1); +has 'type' => (is => 'ro', isa => 'Str', required => 1); + +1; diff --git a/lib/SQL/Translator/Object/Procedure.pm b/lib/SQL/Translator/Object/Procedure.pm new file mode 100644 index 0000000..d34cc8d --- /dev/null +++ b/lib/SQL/Translator/Object/Procedure.pm @@ -0,0 +1,4 @@ +package SQL::Translator::Object::Procedure; +use Moose; + +1; diff --git a/lib/SQL/Translator/Object/Schema.pm b/lib/SQL/Translator/Object/Schema.pm new file mode 100644 index 0000000..7c151b9 --- /dev/null +++ b/lib/SQL/Translator/Object/Schema.pm @@ -0,0 +1,8 @@ +package SQL::Translator::Object::Schema; +use Moose; + +has 'tables' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Table]', required => 1); +has 'views' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::View]', required => 0); +has 'procedures' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Procedure]', required => 0); + +1; diff --git a/lib/SQL/Translator/Object/Table.pm b/lib/SQL/Translator/Object/Table.pm new file mode 100644 index 0000000..ac42c6e --- /dev/null +++ b/lib/SQL/Translator/Object/Table.pm @@ -0,0 +1,9 @@ +package SQL::Translator::Object::Table; +use Moose; + +has 'name' => (is => 'ro', isa => 'Str', required => 1); +has 'columns' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Column]', required => 1); +has 'indexes' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Index]', required => 0); +has 'constraints' => (is => 'ro', isa => 'ArrayRef[SQL::Translator::Object::Constraint]', required => 0); + +1; diff --git a/lib/SQL/Translator/Object/Trigger.pm b/lib/SQL/Translator/Object/Trigger.pm new file mode 100644 index 0000000..c9c9ed2 --- /dev/null +++ b/lib/SQL/Translator/Object/Trigger.pm @@ -0,0 +1,6 @@ +package SQL::Translator::Object::Trigger; +use Moose; + +has 'name' => (is => 'ro', isa => 'Str', required => 1); + +1; diff --git a/lib/SQL/Translator/Object/View.pm b/lib/SQL/Translator/Object/View.pm new file mode 100644 index 0000000..f0b4995 --- /dev/null +++ b/lib/SQL/Translator/Object/View.pm @@ -0,0 +1,7 @@ +package SQL::Translator::Object::View; +use Moose; + +extends 'SQL::Translator::Object::Table'; +has 'sql' => (is => 'ro', isa => 'Str', required => 1); + +1;