You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
355 lines
11 KiB
PHP
355 lines
11 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
*/
|
|
final class Version20240331093351 extends AbstractMigration
|
|
{
|
|
|
|
public const TESTS = [[
|
|
'id' => 1,
|
|
'name' => 'Trial1'
|
|
]];
|
|
|
|
public const QUESTIONS = [
|
|
[
|
|
'id' => 1,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "1"}, {"type": "op", "value": "+"}, {"type": "number", "value": "1"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '3'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '2'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '0'
|
|
]]
|
|
],
|
|
],
|
|
[
|
|
'id' => 2,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "2"}, {"type": "op", "value": "+"}, {"type": "number", "value": "2"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '4'
|
|
]],
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '3'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '1'
|
|
]
|
|
],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '10'
|
|
]]
|
|
],
|
|
],
|
|
[
|
|
'id' => 3,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "3"}, {"type": "op", "value": "+"}, {"type": "number", "value": "3"}]',
|
|
'answers' => [
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '1'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '5'
|
|
]
|
|
],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '1'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '6'
|
|
]],
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '2'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '4'
|
|
]
|
|
]
|
|
],
|
|
],
|
|
[
|
|
'id' => 4,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "4"}, {"type": "op", "value": "+"}, {"type": "number", "value": "4"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '8'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '4'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '0'
|
|
]],
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '0'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '8'
|
|
]
|
|
],
|
|
|
|
],
|
|
],
|
|
[
|
|
'id' => 5,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "5"}, {"type": "op", "value": "+"}, {"type": "number", "value": "5"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '6'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '18'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '10'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '9'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '0'
|
|
]],
|
|
],
|
|
],
|
|
[
|
|
'id' => 6,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "6"}, {"type": "op", "value": "+"}, {"type": "number", "value": "6"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '3'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '9'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '0'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '12'
|
|
]],
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '5'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '7'
|
|
]
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'id' => 7,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "7"}, {"type": "op", "value": "+"}, {"type": "number", "value": "7"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '5'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '14'
|
|
]],
|
|
],
|
|
],
|
|
[
|
|
'id' => 8,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "8"}, {"type": "op", "value": "+"}, {"type": "number", "value": "8"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '16'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '12'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '9'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '5'
|
|
]],
|
|
],
|
|
],
|
|
[
|
|
'id' => 9,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "9"}, {"type": "op", "value": "+"}, {"type": "number", "value": "9"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '18'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '9'
|
|
]],
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '17'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '1'
|
|
]
|
|
],
|
|
[
|
|
[
|
|
'type' => 'number',
|
|
'value' => '2'
|
|
],
|
|
[
|
|
'type' => 'op',
|
|
'value' => '+'
|
|
],
|
|
[
|
|
'type' => 'number',
|
|
'value' => '16'
|
|
]
|
|
],
|
|
],
|
|
],
|
|
[
|
|
'id' => 10,
|
|
'test_id' => 1,
|
|
'prompt' => '[{"type": "number", "value": "10"}, {"type": "op", "value": "+"}, {"type": "number", "value": "10"}]',
|
|
'answers' => [
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '0'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '2'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '8'
|
|
]],
|
|
[[
|
|
'type' => 'number',
|
|
'value' => '20'
|
|
]],
|
|
],
|
|
],
|
|
];
|
|
|
|
public function getDescription(): string
|
|
{
|
|
return 'Initial';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
// this up() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE SEQUENCE question_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
|
$this->addSql('CREATE SEQUENCE test_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
|
$this->addSql('CREATE TABLE question (id INT NOT NULL, test_id INT NOT NULL, prompt JSON NOT NULL, answers JSON NOT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('CREATE INDEX IDX_B6F7494E1E5D0459 ON question (test_id)');
|
|
$this->addSql('CREATE TABLE test (id INT NOT NULL, name VARCHAR(60) NOT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('ALTER TABLE question ADD CONSTRAINT FK_B6F7494E1E5D0459 FOREIGN KEY (test_id) REFERENCES test (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
$this->addSql('CREATE SEQUENCE user_answer_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
|
$this->addSql('CREATE TABLE user_answer (id INT NOT NULL, question_id INT NOT NULL, date_created TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, is_correct BOOLEAN NOT NULL, answer JSON NOT NULL, PRIMARY KEY(id))');
|
|
$this->addSql('CREATE INDEX IDX_BF8F51181E27F6BF ON user_answer (question_id)');
|
|
$this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F51181E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('CREATE SCHEMA public');
|
|
$this->addSql('DROP SEQUENCE question_id_seq CASCADE');
|
|
$this->addSql('DROP SEQUENCE test_id_seq CASCADE');
|
|
$this->addSql('ALTER TABLE question DROP CONSTRAINT FK_B6F7494E1E5D0459');
|
|
$this->addSql('DROP TABLE question');
|
|
$this->addSql('DROP TABLE test');
|
|
$this->addSql('DROP SEQUENCE user_answer_id_seq CASCADE');
|
|
$this->addSql('ALTER TABLE user_answer DROP CONSTRAINT FK_BF8F51181E27F6BF');
|
|
$this->addSql('DROP TABLE user_answer');
|
|
}
|
|
}
|