Version20150423093100.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. namespace Application\Migrations\Schema\V110;
  4. use Application\Migrations\AbstractMigrationChamilo;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\DBAL\Types\Type;
  7. /**
  8. * Class Version20150423093100
  9. *
  10. * @package Application\Migrations\Schema\V110
  11. */
  12. class Version20150423093100 extends AbstractMigrationChamilo
  13. {
  14. /**
  15. * @param Schema $schema
  16. *
  17. * @throws \Doctrine\DBAL\Schema\SchemaException
  18. */
  19. public function up(Schema $schema)
  20. {
  21. // Sequence changes
  22. if (!$schema->hasTable('sequence_rule')) {
  23. $sequenceRule = $schema->createTable('sequence_rule');
  24. $sequenceRule->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  25. $sequenceRule->addColumn('text', Type::TEXT);
  26. $sequenceRule->setPrimaryKey(['id']);
  27. }
  28. if (!$schema->hasTable('sequence_condition')) {
  29. $sequenceCondition = $schema->createTable('sequence_condition');
  30. $sequenceCondition->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  31. $sequenceCondition->addColumn('description', Type::TEXT);
  32. $sequenceCondition->addColumn('mat_op', Type::INTEGER);
  33. $sequenceCondition->addColumn('param', Type::FLOAT);
  34. $sequenceCondition->addColumn('act_true', Type::INTEGER);
  35. $sequenceCondition->addColumn('act_false', Type::INTEGER);
  36. $sequenceCondition->setPrimaryKey(['id']);
  37. }
  38. if (!$schema->hasTable('sequence_rule_condition')) {
  39. $sequenceRuleCondition = $schema->createTable('sequence_rule_condition');
  40. $sequenceRuleCondition->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  41. $sequenceRuleCondition->addColumn('sequence_rule_id', Type::INTEGER)->setNotnull(false);
  42. $sequenceRuleCondition->addColumn('sequence_condition_id', Type::INTEGER)->setNotnull(false);
  43. $sequenceRuleCondition->setPrimaryKey(['id']);
  44. $sequenceRuleCondition->addIndex(['sequence_rule_id']);
  45. $sequenceRuleCondition->addIndex(['sequence_condition_id']);
  46. $sequenceRuleCondition->addForeignKeyConstraint('sequence_condition', ['sequence_condition_id'], ['id']);
  47. $sequenceRuleCondition->addForeignKeyConstraint('sequence_rule', ['sequence_rule_id'], ['id']);
  48. }
  49. if (!$schema->hasTable('sequence_method')) {
  50. $sequenceMethod = $schema->createTable('sequence_method');
  51. $sequenceMethod->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  52. $sequenceMethod->addColumn('description', Type::TEXT);
  53. $sequenceMethod->addColumn('formula', Type::TEXT);
  54. $sequenceMethod->addColumn('assign', Type::INTEGER);
  55. $sequenceMethod->addColumn('met_type', Type::INTEGER);
  56. $sequenceMethod->addColumn('act_false', Type::INTEGER);
  57. $sequenceMethod->setPrimaryKey(['id']);
  58. }
  59. if (!$schema->hasTable('sequence_rule_method')) {
  60. $sequenceRuleMethod = $schema->createTable('sequence_rule_method');
  61. $sequenceRuleMethod->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  62. $sequenceRuleMethod->addColumn('sequence_rule_id', Type::INTEGER)->setNotnull(false);
  63. $sequenceRuleMethod->addColumn('sequence_method_id', Type::INTEGER)->setNotnull(false);
  64. $sequenceRuleMethod->addColumn('method_order', Type::INTEGER);
  65. $sequenceRuleMethod->setPrimaryKey(['id']);
  66. $sequenceRuleMethod->addIndex(['sequence_rule_id']);
  67. $sequenceRuleMethod->addIndex(['sequence_method_id']);
  68. $sequenceRuleMethod->addForeignKeyConstraint('sequence_method', ['sequence_method_id'], ['id']);
  69. $sequenceRuleMethod->addForeignKeyConstraint('sequence_rule', ['sequence_rule_id'], ['id']);
  70. }
  71. if (!$schema->hasTable('sequence_variable')) {
  72. $sequenceVariable = $schema->createTable('sequence_variable');
  73. $sequenceVariable->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  74. $sequenceVariable->addColumn('name', Type::STRING)->setLength(255)->setNotnull(false);
  75. $sequenceVariable->addColumn('description', Type::TEXT)->setNotnull(false);
  76. $sequenceVariable->addColumn('default_val', Type::STRING)->setLength(255)->setNotnull(false);
  77. $sequenceVariable->setPrimaryKey(['id']);
  78. }
  79. if (!$schema->hasTable('sequence_formula')) {
  80. $sequenceFormula = $schema->createTable('sequence_formula');
  81. $sequenceFormula->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  82. $sequenceFormula->addColumn('sequence_method_id', Type::INTEGER)->setNotnull(false);
  83. $sequenceFormula->addColumn('sequence_variable_id', Type::INTEGER)->setNotnull(false);
  84. $sequenceFormula->setPrimaryKey(['id']);
  85. $sequenceFormula->addIndex(['sequence_method_id']);
  86. $sequenceFormula->addIndex(['sequence_variable_id']);
  87. $sequenceFormula->addForeignKeyConstraint('sequence_variable', ['sequence_variable_id'], ['id']);
  88. $sequenceFormula->addForeignKeyConstraint('sequence_method', ['sequence_method_id'], ['id']);
  89. }
  90. if (!$schema->hasTable('sequence_valid')) {
  91. $sequenceValid = $schema->createTable('sequence_valid');
  92. $sequenceValid->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  93. $sequenceValid->addColumn('sequence_variable_id', Type::INTEGER)->setNotnull(false);
  94. $sequenceValid->addColumn('sequence_condition_id', Type::INTEGER)->setNotnull(false);
  95. $sequenceValid->setPrimaryKey(['id']);
  96. $sequenceValid->addIndex(['sequence_variable_id']);
  97. $sequenceValid->addIndex(['sequence_condition_id']);
  98. $sequenceValid->addForeignKeyConstraint('sequence_condition', ['sequence_condition_id'], ['id']);
  99. $sequenceValid->addForeignKeyConstraint('sequence_variable', ['sequence_variable_id'], ['id']);
  100. }
  101. if (!$schema->hasTable('sequence_type_entity')) {
  102. $sequenceTypeEntity = $schema->createTable('sequence_type_entity');
  103. $sequenceTypeEntity->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  104. $sequenceTypeEntity->addColumn('name', Type::STRING)->setLength(255);
  105. $sequenceTypeEntity->addColumn('description', Type::TEXT);
  106. $sequenceTypeEntity->addColumn('ent_table', Type::STRING)->setLength(255);
  107. $sequenceTypeEntity->setPrimaryKey(['id']);
  108. }
  109. if (!$schema->hasTable('sequence_row_entity')) {
  110. $sequenceRowEntity = $schema->createTable('sequence_row_entity');
  111. $sequenceRowEntity->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  112. $sequenceRowEntity->addColumn('sequence_type_entity_id', Type::INTEGER)->setNotnull(false);
  113. $sequenceRowEntity->addColumn('c_id', Type::INTEGER);
  114. $sequenceRowEntity->addColumn('session_id', Type::INTEGER);
  115. $sequenceRowEntity->addColumn('row_id', Type::INTEGER);
  116. $sequenceRowEntity->addColumn('name', Type::STRING)->setLength(255);
  117. $sequenceRowEntity->setPrimaryKey(['id']);
  118. $sequenceRowEntity->addIndex(['sequence_type_entity_id']);
  119. $sequenceRowEntity->addForeignKeyConstraint('sequence_type_entity', ['sequence_type_entity_id'], ['id']);
  120. }
  121. if (!$schema->hasTable('sequence')) {
  122. $sequence = $schema->createTable('sequence');
  123. $sequence->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  124. $sequence->addColumn('name', Type::STRING)->setLength(255);
  125. $sequence->addColumn('graph', Type::TEXT)->setNotnull(false);
  126. $sequence->addColumn('created_at', Type::DATETIME);
  127. $sequence->addColumn('updated_at', Type::DATETIME);
  128. $sequence->setPrimaryKey(['id']);
  129. }
  130. if (!$schema->hasTable('sequence_value')) {
  131. $sequenceValue = $schema->createTable('sequence_value');
  132. $sequenceValue->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  133. $sequenceValue->addColumn('sequence_row_entity_id', Type::INTEGER)->setNotnull(false);
  134. $sequenceValue->addColumn('user_id', Type::INTEGER);
  135. $sequenceValue->addColumn('advance', Type::FLOAT);
  136. $sequenceValue->addColumn('complete_items', Type::INTEGER);
  137. $sequenceValue->addColumn('total_items', Type::INTEGER);
  138. $sequenceValue->addColumn('success', Type::BOOLEAN);
  139. $sequenceValue->addColumn('success_date', Type::DATETIME)->setNotnull(false);
  140. $sequenceValue->addColumn('available', Type::BOOLEAN);
  141. $sequenceValue->addColumn('available_start_date', Type::DATETIME)->setNotnull(false);
  142. $sequenceValue->addColumn('available_end_date', Type::DATETIME)->setNotnull(false);
  143. $sequenceValue->setPrimaryKey(['id']);
  144. $sequenceValue->addIndex(['sequence_row_entity_id']);
  145. $sequenceValue->addForeignKeyConstraint('sequence_row_entity', ['sequence_row_entity_id'], ['id']);
  146. }
  147. if (!$schema->hasTable('sequence_resource')) {
  148. $sequenceResource = $schema->createTable('sequence_resource');
  149. $sequenceResource->addColumn('id', Type::INTEGER)->setAutoincrement(true);
  150. $sequenceResource->addColumn('sequence_id', Type::INTEGER)->setNotnull(false);
  151. $sequenceResource->addColumn('type', Type::INTEGER);
  152. $sequenceResource->addColumn('resource_id', Type::INTEGER);
  153. $sequenceResource->setPrimaryKey(['id']);
  154. $sequenceResource->addIndex(['sequence_id']);
  155. $sequenceResource->addForeignKeyConstraint('sequence', ['sequence_id'], ['id']);
  156. }
  157. }
  158. /**
  159. * We don't allow downgrades yet
  160. * @param Schema $schema
  161. */
  162. public function down(Schema $schema)
  163. {
  164. }
  165. }