Version20150529164400.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 as TableColumnType;
  7. /**
  8. * Session date changes
  9. */
  10. class Version20150529164400 extends AbstractMigrationChamilo
  11. {
  12. /**
  13. * @param Schema $schema
  14. */
  15. public function up(Schema $schema)
  16. {
  17. if (!$schema->hasTable('gradebook_score_log')) {
  18. $gradebookScoreLog = $schema->createTable('gradebook_score_log');
  19. $gradebookScoreLog->addColumn(
  20. 'id',
  21. TableColumnType::INTEGER,
  22. ['unsigned' => true, 'autoincrement' => true, 'notnull' => true]
  23. );
  24. $gradebookScoreLog->addColumn(
  25. 'category_id',
  26. TableColumnType::INTEGER,
  27. ['unsigned' => true, 'notnull' => true]
  28. );
  29. $gradebookScoreLog->addColumn(
  30. 'user_id',
  31. TableColumnType::INTEGER,
  32. ['unsigned' => true, 'notnull' => true]
  33. );
  34. $gradebookScoreLog->addColumn(
  35. 'score',
  36. TableColumnType::FLOAT,
  37. ['notnull' => true, 'scale' => 0, 'precision' => 10]
  38. );
  39. $gradebookScoreLog->addColumn(
  40. 'registered_at',
  41. TableColumnType::DATETIME,
  42. ['notnull' => true]
  43. );
  44. $gradebookScoreLog->setPrimaryKey(['id']);
  45. $gradebookScoreLog->addIndex(
  46. ['user_id'],
  47. 'idx_gradebook_score_log_user'
  48. );
  49. $gradebookScoreLog->addIndex(
  50. ['user_id', 'category_id'],
  51. 'idx_gradebook_score_log_user_category'
  52. );
  53. }
  54. }
  55. /**
  56. * @param Schema $schema
  57. */
  58. public function down(Schema $schema)
  59. {
  60. $schema->dropTable('gradebook_score_log');
  61. }
  62. }