Permalink
Browse files

initial migration

  • Loading branch information...
1 parent dc72a05 commit dade1725edec6b705fc17e11d7e57b257b2dde3f @frioux committed Sep 19, 2012
@@ -0,0 +1,7 @@
+CREATE TABLE "dbix_class_deploymenthandler_versions" (
+ "id" INTEGER PRIMARY KEY NOT NULL,
+ "version" varchar(50) NOT NULL,
+ "ddl" text,
+ "upgrade_sql" text
+);
+CREATE UNIQUE INDEX "dbix_class_deploymenthandler_versions_version" ON "dbix_class_deploymenthandler_versions" ("version")
@@ -0,0 +1,63 @@
+CREATE TABLE "drinks" (
+ "id" INTEGER PRIMARY KEY NOT NULL,
+ "description" ntext NOT NULL,
+ "source" nvarchar(50),
+ "variant_of_drink_id" int,
+ FOREIGN KEY ("variant_of_drink_id") REFERENCES "drinks"("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+CREATE INDEX "drinks_idx_variant_of_drink_id" ON "drinks" ("variant_of_drink_id");
+CREATE TABLE "ingredients" (
+ "id" INTEGER PRIMARY KEY NOT NULL,
+ "kind_of_id" int,
+ "materialized_path" varchar(255),
+ "name" nvarchar(50) NOT NULL,
+ "description" ntext,
+ FOREIGN KEY ("kind_of_id") REFERENCES "ingredients"("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+CREATE INDEX "ingredients_idx_kind_of_id" ON "ingredients" ("kind_of_id");
+CREATE UNIQUE INDEX "ingredients_name" ON "ingredients" ("name");
+CREATE TABLE "units" (
+ "id" INTEGER PRIMARY KEY NOT NULL,
+ "name" nvarchar(50) NOT NULL,
+ "gills" float
+);
+CREATE UNIQUE INDEX "units_name" ON "units" ("name");
+CREATE TABLE "users" (
+ "id" INTEGER PRIMARY KEY NOT NULL,
+ "name" nvarchar(50) NOT NULL
+);
+CREATE UNIQUE INDEX "users_name" ON "users" ("name");
+CREATE TABLE "drink_names" (
+ "id" INTEGER PRIMARY KEY NOT NULL,
+ "drink_id" int NOT NULL,
+ "name" nvarchar(50) NOT NULL,
+ "order" float NOT NULL,
+ FOREIGN KEY ("drink_id") REFERENCES "drinks"("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+CREATE INDEX "drink_names_idx_drink_id" ON "drink_names" ("drink_id");
+CREATE UNIQUE INDEX "drink_names_drink_id_order" ON "drink_names" ("drink_id", "order");
+CREATE UNIQUE INDEX "drink_names_name" ON "drink_names" ("name");
+CREATE TABLE "inventory_items" (
+ "ingredient_id" int NOT NULL,
+ "user_id" int NOT NULL,
+ PRIMARY KEY ("ingredient_id", "user_id"),
+ FOREIGN KEY ("ingredient_id") REFERENCES "ingredients"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE
+);
+CREATE INDEX "inventory_items_idx_ingredient_id" ON "inventory_items" ("ingredient_id");
+CREATE INDEX "inventory_items_idx_user_id" ON "inventory_items" ("user_id");
+CREATE TABLE "drink_ingredients" (
+ "drink_id" int NOT NULL,
+ "ingredient_id" int NOT NULL,
+ "unit_id" int,
+ "amount" float,
+ "arbitrary_amount" nvarchar(50),
+ "notes" ntext,
+ PRIMARY KEY ("drink_id", "ingredient_id"),
+ FOREIGN KEY ("drink_id") REFERENCES "drinks"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ FOREIGN KEY ("ingredient_id") REFERENCES "ingredients"("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ FOREIGN KEY ("unit_id") REFERENCES "units"("id")
+);
+CREATE INDEX "drink_ingredients_idx_drink_id" ON "drink_ingredients" ("drink_id");
+CREATE INDEX "drink_ingredients_idx_ingredient_id" ON "drink_ingredients" ("ingredient_id");
+CREATE INDEX "drink_ingredients_idx_unit_id" ON "drink_ingredients" ("unit_id")
@@ -0,0 +1,21 @@
+#!perl
+
+use 5.16.1;
+use warnings;
+
+use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::ScriptHelpers 'schema_from_schema_loader';
+
+schema_from_schema_loader({ naming => 'v7' }, sub {
+ my ($schema, $version_set) = @_;
+
+ $schema->resultset('Unit')->populate([
+ [qw(name gills)],
+ [ounce => 1 / 4 ] ,
+ [tablespoon => 1 / 4 / 2 ] ,
+ [teaspoon => 1 / 4 / 2 / 3 ] ,
+ [dash => undef ] ,
+ ]);
+
+ $schema->resultset('User')->create({ name => 'frew' });
+});
+
@@ -0,0 +1,95 @@
+---
+schema:
+ procedures: {}
+ tables:
+ dbix_class_deploymenthandler_versions:
+ constraints:
+ - deferrable: 1
+ expression: ''
+ fields:
+ - id
+ match_type: ''
+ name: ''
+ on_delete: ''
+ on_update: ''
+ options: []
+ reference_fields: []
+ reference_table: ''
+ type: PRIMARY KEY
+ - deferrable: 1
+ expression: ''
+ fields:
+ - version
+ match_type: ''
+ name: dbix_class_deploymenthandler_versions_version
+ on_delete: ''
+ on_update: ''
+ options: []
+ reference_fields: []
+ reference_table: ''
+ type: UNIQUE
+ fields:
+ ddl:
+ data_type: text
+ default_value: ~
+ is_nullable: 1
+ is_primary_key: 0
+ is_unique: 0
+ name: ddl
+ order: 3
+ size:
+ - 0
+ id:
+ data_type: int
+ default_value: ~
+ is_auto_increment: 1
+ is_nullable: 0
+ is_primary_key: 1
+ is_unique: 0
+ name: id
+ order: 1
+ size:
+ - 0
+ upgrade_sql:
+ data_type: text
+ default_value: ~
+ is_nullable: 1
+ is_primary_key: 0
+ is_unique: 0
+ name: upgrade_sql
+ order: 4
+ size:
+ - 0
+ version:
+ data_type: varchar
+ default_value: ~
+ is_nullable: 0
+ is_primary_key: 0
+ is_unique: 1
+ name: version
+ order: 2
+ size:
+ - 50
+ indices: []
+ name: dbix_class_deploymenthandler_versions
+ options: []
+ order: 1
+ triggers: {}
+ views: {}
+translator:
+ add_drop_table: 0
+ filename: ~
+ no_comments: 1
+ parser_args:
+ DBIx::Class::Schema: ~
+ DBIx::Schema: ~
+ package: DU::Schema
+ sources:
+ - __VERSION
+ parser_type: SQL::Translator::Parser::DBIx::Class
+ producer_args:
+ no_transaction: 1
+ producer_type: SQL::Translator::Producer::YAML
+ show_warnings: 0
+ trace: 0
+ version: 0.11012
Oops, something went wrong.

0 comments on commit dade172

Please sign in to comment.