Initial commit

This commit is contained in:
2020-01-27 08:56:08 +01:00
commit b7525048d6
27129 changed files with 3409855 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="config.xml" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
<file name="create.sql" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
<file name="insert.sql" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
<file name="module.xml" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
<file name="routing.xml" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
<file name="schema.xml" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
<file name="thelia.sql" server="51.254.220.106//web/" local="131351944800000000" remote="131351944800000000" />
</dwsync>

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://thelia.net/schema/dic/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<loops>
<!-- sample definition
<loop name="MySuperLoop" class="Contest\Loop\MySuperLoop" />
-->
<loop name="game" class="Contest\Loop\Game"/>
<loop name="question" class="Contest\Loop\Question"/>
<loop name="answer" class="Contest\Loop\Answer"/>
<loop name="participate" class="Contest\Loop\Participate"/>
</loops>
<forms>
<!--
<form name="MyFormName" class="Contest\Form\MySuperForm" />
-->
<form name="game.create" class="Contest\Form\GameCreateForm"/>
<form name="game.update" class="Contest\Form\GameUpdateForm"/>
<form name="question.create" class="Contest\Form\QuestionCreateForm"/>
<form name="question.update" class="Contest\Form\QuestionUpdateForm"/>
<form name="answer.create" class="Contest\Form\AnswerCreateForm"/>
<form name="answer.update" class="Contest\Form\AnswerUpdateForm"/>
<form name="participate.create" class="Contest\Form\ParticipateCreateForm"/>
<form name="participate.update" class="Contest\Form\ParticipateUpdateForm"/>
</forms>
<commands>
<!--
<command class="Contest\Command\MySuperCommand" />
-->
</commands>
<!--
<services>
</services>
-->
<hooks>
<hook id="contest.admin.hook" class="Contest\Hook\BackHook" scope="request">
<tag name="hook.event_listener" event="main.top-menu-tools" type="back" method="onTopMenuTools"/>
<argument type="service" id="router.contest"/>
</hook>
<hook id="contest.config.hook" class="Contest\Hook\ConfigHook" scope="request">
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfig" />
<tag name="hook.event_listener" event="module.config-js" type="back" method="onModuleConfigInsertJS" />
</hook>
</hooks>
<!--
<exports>
</exports>
-->
<!--
<imports>
</imports>
-->
<services>
<service id="action.contest.game_table" class="Contest\Action\GameAction">
<tag name="kernel.event_subscriber"/>
</service>
<service id="contest.form.type.game_id" class="Contest\Form\Type\GameIdType">
<argument id="thelia.translator" type="service"/>
<tag name="thelia.form.type"/>
</service>
<service id="action.contest.question_table" class="Contest\Action\QuestionAction">
<tag name="kernel.event_subscriber"/>
</service>
<service id="contest.form.type.question_id" class="Contest\Form\Type\QuestionIdType">
<argument id="thelia.translator" type="service"/>
<tag name="thelia.form.type"/>
</service>
<service id="action.contest.answer_table" class="Contest\Action\AnswerAction">
<tag name="kernel.event_subscriber"/>
</service>
<service id="contest.form.type.answer_id" class="Contest\Form\Type\AnswerIdType">
<argument id="thelia.translator" type="service"/>
<tag name="thelia.form.type"/>
</service>
<service id="action.contest.participate_table" class="Contest\Action\ParticipateAction">
<tag name="kernel.event_subscriber"/>
</service>
<service id="contest.form.type.participate_id" class="Contest\Form\Type\ParticipateIdType">
<argument id="thelia.translator" type="service"/>
<tag name="thelia.form.type"/>
</service>
<service id="contest.mail" class="Contest\EventListeners\MailListener" scope="request">
<argument type="service" id="thelia.parser" />
<argument type="service" id="mailer"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -0,0 +1,216 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- game
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `game`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- question
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `question`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT DEFAULT 0 NOT NULL,
`game_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`),
INDEX `FI_game_id` (`game_id`),
CONSTRAINT `fk_game_id`
FOREIGN KEY (`game_id`)
REFERENCES `game` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- answer
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `answer`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT DEFAULT 0 NOT NULL,
`correct` TINYINT DEFAULT 0 NOT NULL,
`question_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`),
INDEX `FI_question_id` (`question_id`),
CONSTRAINT `fk_question_id`
FOREIGN KEY (`question_id`)
REFERENCES `question` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- participate
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `participate`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`email` VARCHAR(255) NOT NULL,
`win` TINYINT DEFAULT 0 NOT NULL,
`game_id` INTEGER NOT NULL,
`customer_id` INTEGER,
PRIMARY KEY (`id`),
INDEX `FI_game_participate_id` (`game_id`),
INDEX `FI_game_customer_id` (`customer_id`),
CONSTRAINT `fk_game_participate_id`
FOREIGN KEY (`game_id`)
REFERENCES `game` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `fk_game_customer_id`
FOREIGN KEY (`customer_id`)
REFERENCES `customer` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- game_i18n
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `game_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `game_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `game` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- question_i18n
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `question_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `question_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `question` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- answer_i18n
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `answer_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `answer_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `answer` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- game_version
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `game_version`
(
`id` INTEGER NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`question_ids` TEXT,
`question_versions` TEXT,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `game_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `game` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- question_version
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `question_version`
(
`id` INTEGER NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`game_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`game_id_version` INTEGER DEFAULT 0,
`answer_ids` TEXT,
`answer_versions` TEXT,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `question_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `question` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- answer_version
-- ---------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `answer_version`
(
`id` INTEGER NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`correct` TINYINT DEFAULT 0 NOT NULL,
`question_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`question_id_version` INTEGER DEFAULT 0,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `answer_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `answer` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_1.xsd">
<fullnamespace>Contest\Contest</fullnamespace>
<descriptive locale="en_US">
<title>Contest</title>
</descriptive>
<descriptive locale="fr_FR">
<title>Jeux concours</title>
</descriptive>
<!-- <logo></logo> -->
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.1</version>
<author>
<name>Penalver Antony</name>
<email>apenalver@gmail.com</email>
</author>
<type>classic</type>
<thelia>2.1.0</thelia>
<stability>other</stability>
</module>

View File

@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<!--
if a /admin/module/contest/ route is provided, a "Configuration" button will be displayed
for the module in the module list. Clicking this button will invoke this route.
<route id="my_route_id" path="/admin/module/contest">
<default key="_controller">Contest\Full\Class\Name\Of\YourConfigurationController::methodName</default>
</route>
<route id="my_route_id" path="/admin/module/contest/route-name">
<default key="_controller">Contest\Full\Class\Name\Of\YourAdminController::methodName</default>
</route>
<route id="my_route_id" path="/my/route/name">
<default key="_controller">Contest\Full\Class\Name\Of\YourOtherController::methodName</default>
</route>
...add as many routes as required.
<route>
...
</route>
-->
<route id="contest.game.list" path="/admin/module/Contest/game" methods="get">
<default key="_controller">Contest:Game:default</default>
</route>
<route id="contest.game.create" path="/admin/module/Contest/game" methods="post">
<default key="_controller">Contest:Game:create</default>
</route>
<route id="contest.game.view" path="/admin/module/Contest/game/edit" methods="get">
<default key="_controller">Contest:Game:update</default>
</route>
<route id="contest.game.edit" path="/admin/module/Contest/game/edit" methods="post">
<default key="_controller">Contest:Game:processUpdate</default>
</route>
<route id="contest.game.delete" path="/admin/module/Contest/game/delete" methods="post">
<default key="_controller">Contest:Game:delete</default>
</route>
<route id="contest.game.toggle_visibility" path="/admin/module/Contest/game/toggleVisibility" methods="get">
<default key="_controller">Contest:Game:setToggleVisibility</default>
</route>
<route id="contest.question.list" path="/admin/module/Contest/question" methods="get">
<default key="_controller">Contest:Question:default</default>
</route>
<route id="contest.question.create" path="/admin/module/Contest/question" methods="post">
<default key="_controller">Contest:Question:create</default>
</route>
<route id="contest.question.view" path="/admin/module/Contest/question/edit" methods="get">
<default key="_controller">Contest:Question:update</default>
</route>
<route id="contest.question.edit" path="/admin/module/Contest/question/edit" methods="post">
<default key="_controller">Contest:Question:processUpdate</default>
</route>
<route id="contest.question.delete" path="/admin/module/Contest/question/delete" methods="post">
<default key="_controller">Contest:Question:delete</default>
</route>
<route id="contest.question.toggle_visibility" path="/admin/module/Contest/question/toggleVisibility" methods="get">
<default key="_controller">Contest:Question:setToggleVisibility</default>
</route>
<route id="contest.answer.list" path="/admin/module/Contest/answer" methods="get">
<default key="_controller">Contest:Answer:default</default>
</route>
<route id="contest.answer.create" path="/admin/module/Contest/answer" methods="post">
<default key="_controller">Contest:Answer:create</default>
</route>
<route id="contest.answer.view" path="/admin/module/Contest/answer/edit" methods="get">
<default key="_controller">Contest:Answer:update</default>
</route>
<route id="contest.answer.edit" path="/admin/module/Contest/answer/edit" methods="post">
<default key="_controller">Contest:Answer:processUpdate</default>
</route>
<route id="contest.answer.delete" path="/admin/module/Contest/answer/delete" methods="post">
<default key="_controller">Contest:Answer:delete</default>
</route>
<route id="contest.answer.toggle_visibility" path="/admin/module/Contest/answer/toggleVisibility" methods="get">
<default key="_controller">Contest:Answer:setToggleVisibility</default>
</route>
<route id="contest.participate.list" path="/admin/module/Contest/participate" methods="get">
<default key="_controller">Contest:Participate:default</default>
</route>
<route id="contest.participate.create" path="/admin/module/Contest/participate" methods="post">
<default key="_controller">Contest:Participate:create</default>
</route>
<route id="contest.participate.view" path="/admin/module/Contest/participate/edit" methods="get">
<default key="_controller">Contest:Participate:update</default>
</route>
<route id="contest.participate.edit" path="/admin/module/Contest/participate/edit" methods="post">
<default key="_controller">Contest:Participate:processUpdate</default>
</route>
<route id="contest.participate.winner" path="/admin/module/Contest/participate/winner/{id}" methods="get">
<default key="_controller">Contest:Participate:generateWinner</default>
<requirement key="id">\d+</requirement>
</route>
<route id="contest.participate.winner.mail" path="/admin/module/Contest/participate/winner/mail/{game_id}/{id}" methods="get">
<default key="_controller">Contest:Participate:processMailWinner</default>
<requirement key="game_id">\d+</requirement>
<requirement key="id">\d+</requirement>
</route>
<route id="contest.config.toggle.win" path="/admin/module/Contest/win/toggle" methods="post">
<default key="_controller">Contest:Configuration:toggleWinOption</default>
</route>
<route id="contest.config.toggle.connect" path="/admin/module/Contest/connect/toggle" methods="post">
<default key="_controller">Contest:Configuration:toggleConnectOption</default>
</route>
<route id="contest.config.toggle.friend" path="/admin/module/Contest/friend/toggle" methods="post">
<default key="_controller">Contest:Configuration:toggleFriendOption</default>
</route>
<route id="contest.config.friend.max" path="/admin/module/Contest/friend/max/{val}" methods="post">
<default key="_controller">Contest:Configuration:setFriendMaxOption</default>
<requirement key="val">\d+</requirement>
</route>
<route id="contest.config.participate.max" path="/admin/module/Contest/participation/max/{val}" methods="post">
<default key="_controller">Contest:Configuration:setMaxParticipateOption</default>
<requirement key="val">\d+</requirement>
</route>
<route id="contest.front.game" path="contest/game/{id}" methods="get">
<default key="_controller">Contest:Front:game</default>
<requirement key="id">\d+</requirement>
</route>
<route id="contest.front.game.process" path="contest/game/{id}" methods="post">
<default key="_controller">Contest:Front:processGame</default>
<requirement key="id">\d+</requirement>
</route>
<route id="contest.front.game.success" path="contest/game/success/{id}" methods="get">
<default key="_controller">Contest:Front:successGame</default>
<requirement key="id">\d+</requirement>
</route>
<route id="contest.front.game.fail" path="contest/game/fail/{id}" methods="get">
<default key="_controller">Contest:Front:failGame</default>
<requirement key="id">\d+</requirement>
</route>
<route id="contest.front.game.end" path="contest/game/end/{id}/participate/{part}" methods="get">
<default key="_controller">Contest:Front:endGame</default>
<requirement key="id">\d+</requirement>
<requirement key="part">\d+</requirement>
</route>
<route id="contest.front.game.invite" path="contest/game/invite/{id}/{part}" methods="post">
<default key="_controller">Contest:Front:sendInvitation</default>
<requirement key="id">\d+</requirement>
<requirement key="part">\d+</requirement>
</route>
</routes>

View File

@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../core/vendor/propel/propel/resources/xsd/database.xsd">
<!--
See propel documentation on http://propelorm.org for all information about schema file
<table name="product_rel" namespace="Contest\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
<column defaultValue="0" name="visible" required="true" type="TINYINT" />
<column defaultValue="0" name="position" required="true" type="INTEGER" />
<column name="title" size="255" type="VARCHAR" />
<column name="description" type="CLOB" />
<column name="chapo" type="LONGVARCHAR" />
<column name="postscriptum" type="LONGVARCHAR" />
<foreign-key foreignTable="product" name="fk_product_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="product_id" />
</foreign-key>
<behavior name="timestampable" />
<behavior name="i18n">
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
</behavior>
<behavior name="versionable">
<parameter name="log_created_at" value="true" />
<parameter name="log_created_by" value="true" />
</behavior>
</table>
-->
<table name="game" namespace="Contest\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER"/>
<column defaultValue="0" name="visible" required="true" type="TINYINT"/>
<column name="title" size="255" type="VARCHAR"/>
<column name="description" type="CLOB"/>
<behavior name="timestampable"/>
<behavior name="i18n">
<parameter name="i18n_columns" value="title, description"/>
</behavior>
<behavior name="versionable">
<parameter name="log_created_at" value="true"/>
<parameter name="log_created_by" value="true"/>
</behavior>
</table>
<table name="question" namespace="Contest\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER"/>
<column defaultValue="0" name="visible" required="true" type="TINYINT"/>
<column name="title" size="255" type="VARCHAR"/>
<column name="description" type="CLOB"/>
<column name="game_id" required="true" type="INTEGER"/>
<foreign-key foreignTable="game" name="fk_game_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="game_id"/>
</foreign-key>
<behavior name="timestampable"/>
<behavior name="i18n">
<parameter name="i18n_columns" value="title, description"/>
</behavior>
<behavior name="versionable">
<parameter name="log_created_at" value="true"/>
<parameter name="log_created_by" value="true"/>
</behavior>
</table>
<table name="answer" namespace="Contest\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER"/>
<column defaultValue="0" name="visible" required="true" type="TINYINT"/>
<column defaultValue="0" name="correct" required="true" type="TINYINT"/>
<column name="title" size="255" type="VARCHAR"/>
<column name="description" type="CLOB"/>
<column name="question_id" required="true" type="INTEGER"/>
<foreign-key foreignTable="question" name="fk_question_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="question_id"/>
</foreign-key>
<behavior name="timestampable"/>
<behavior name="i18n">
<parameter name="i18n_columns" value="title, description"/>
</behavior>
<behavior name="versionable">
<parameter name="log_created_at" value="true"/>
<parameter name="log_created_by" value="true"/>
</behavior>
</table>
<table name="participate" namespace="Contest\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER"/>
<column name="email" required="true" size="255" type="VARCHAR"/>
<column defaultValue="0" name="win" required="true" type="TINYINT"/>
<column name="game_id" required="true" type="INTEGER"/>
<foreign-key foreignTable="game" name="fk_game_participate_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="game_id"/>
</foreign-key>
<column name="customer_id" type="INTEGER"/>
<foreign-key foreignTable="customer" name="fk_game_customer_id" onDelete="CASCADE" onUpdate="RESTRICT">
<reference foreign="id" local="customer_id"/>
</foreign-key>
</table>
<external-schema filename="local/config/schema.xml" referenceOnly="true"/>
</database>

View File

@@ -0,0 +1,236 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- game
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `game`;
CREATE TABLE `game`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- question
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `question`;
CREATE TABLE `question`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT DEFAULT 0 NOT NULL,
`game_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`),
INDEX `FI_game_id` (`game_id`),
CONSTRAINT `fk_game_id`
FOREIGN KEY (`game_id`)
REFERENCES `game` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- answer
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `answer`;
CREATE TABLE `answer`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT DEFAULT 0 NOT NULL,
`correct` TINYINT DEFAULT 0 NOT NULL,
`question_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
PRIMARY KEY (`id`),
INDEX `FI_question_id` (`question_id`),
CONSTRAINT `fk_question_id`
FOREIGN KEY (`question_id`)
REFERENCES `question` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- participate
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `participate`;
CREATE TABLE `participate`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`email` VARCHAR(255) NOT NULL,
`win` TINYINT DEFAULT 0 NOT NULL,
`game_id` INTEGER NOT NULL,
`customer_id` INTEGER,
PRIMARY KEY (`id`),
INDEX `FI_game_participate_id` (`game_id`),
INDEX `FI_game_customer_id` (`customer_id`),
CONSTRAINT `fk_game_participate_id`
FOREIGN KEY (`game_id`)
REFERENCES `game` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE,
CONSTRAINT `fk_game_customer_id`
FOREIGN KEY (`customer_id`)
REFERENCES `customer` (`id`)
ON UPDATE RESTRICT
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- game_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `game_i18n`;
CREATE TABLE `game_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `game_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `game` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- question_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `question_i18n`;
CREATE TABLE `question_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `question_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `question` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- answer_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `answer_i18n`;
CREATE TABLE `answer_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `answer_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `answer` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- game_version
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `game_version`;
CREATE TABLE `game_version`
(
`id` INTEGER NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`question_ids` TEXT,
`question_versions` TEXT,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `game_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `game` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- question_version
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `question_version`;
CREATE TABLE `question_version`
(
`id` INTEGER NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`game_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`game_id_version` INTEGER DEFAULT 0,
`answer_ids` TEXT,
`answer_versions` TEXT,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `question_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `question` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- answer_version
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `answer_version`;
CREATE TABLE `answer_version`
(
`id` INTEGER NOT NULL,
`visible` TINYINT DEFAULT 0 NOT NULL,
`correct` TINYINT DEFAULT 0 NOT NULL,
`question_id` INTEGER NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
`version` INTEGER DEFAULT 0 NOT NULL,
`version_created_at` DATETIME,
`version_created_by` VARCHAR(100),
`question_id_version` INTEGER DEFAULT 0,
PRIMARY KEY (`id`,`version`),
CONSTRAINT `answer_version_FK_1`
FOREIGN KEY (`id`)
REFERENCES `answer` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;