diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee475d4..5d31b56 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,12 +13,27 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: [8.0] + php: [8.0, 8.1] laravel: [9.*] stability: [prefer-stable] include: - laravel: 9.* testbench: ^7.0 + env: + DB_CONNECTION: testing + DB_DATABASE: laravel + DB_USERNAME: root + DB_PASSWORD: TestDB@1234 + services: + mysql: + image: mysql:latest + env: + MYSQL_ALLOW_EMPTY_PASSWORD: false + MYSQL_ROOT_PASSWORD: TestDB@1234 + MYSQL_DATABASE: laravel + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -30,7 +45,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo coverage: none - name: Setup problem matchers @@ -43,3 +58,5 @@ jobs: composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit + env: + DB_PORT: ${{ job.services.mysql.ports['3306'] }} diff --git a/database/migrations/2021_05_22_053359_create_quizzes_table.php b/database/migrations/2021_05_22_053359_create_quizzes_table.php index 1271ef6..75d1a6c 100644 --- a/database/migrations/2021_05_22_053359_create_quizzes_table.php +++ b/database/migrations/2021_05_22_053359_create_quizzes_table.php @@ -102,7 +102,6 @@ public function up() $table->unsignedInteger('order')->default(0); $table->timestamps(); $table->softDeletes(); - $table->unique(['quiz_id', 'question_id']); }); // Quiz Attempts Table diff --git a/database/migrations/2022_08_15_033405_remove_unq_constraint_from_quiz_questions_table.php b/database/migrations/2022_08_15_033405_remove_unq_constraint_from_quiz_questions_table.php new file mode 100644 index 0000000..1cdd595 --- /dev/null +++ b/database/migrations/2022_08_15_033405_remove_unq_constraint_from_quiz_questions_table.php @@ -0,0 +1,45 @@ +tableNames = config('laravel-quiz.table_names'); + } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table($this->tableNames['quiz_questions'], function (Blueprint $table) { + $sm = Schema::getConnection()->getDoctrineSchemaManager(); + $indexesFound = $sm->listTableIndexes($this->tableNames['quiz_questions']); + if (array_key_exists($this->tableNames['quiz_questions'] . "_quiz_id_question_id_unique", $indexesFound)) { + $table->dropForeign($this->tableNames['quiz_questions'] . '_question_id_foreign'); + $table->dropForeign($this->tableNames['quiz_questions'] . '_quiz_id_foreign'); + $table->dropUnique($this->tableNames['quiz_questions'] . "_quiz_id_question_id_unique"); + $table->foreignId('quiz_id')->change()->constrained($this->tableNames['quizzes'])->cascadeOnDelete(); + $table->foreignId('question_id')->change()->constrained($this->tableNames['questions'])->cascadeOnDelete(); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('quiz_questions', function (Blueprint $table) { + // + }); + } +};