From 6f260cbde6e9359fe237b01b9fad8a25f6f9f941 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Thu, 30 Jul 2026 22:14:43 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=82=B9=E3=82=AD=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=82=92=E5=AE=9A=E7=BE=A9=E3=81=97=E3=81=BE=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/db/blueprint.sql | 30 +++++++++++++++++ .../20260730124014_create_stores_table.php | 28 ++++++++++++++++ .../20260730124217_create_employees_table.php | 28 ++++++++++++++++ .../20260730124354_create_customers_table.php | 28 ++++++++++++++++ .../20260730124432_create_histories_table.php | 33 +++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 backend/db/blueprint.sql create mode 100644 backend/db/migrations/20260730124014_create_stores_table.php create mode 100644 backend/db/migrations/20260730124217_create_employees_table.php create mode 100644 backend/db/migrations/20260730124354_create_customers_table.php create mode 100644 backend/db/migrations/20260730124432_create_histories_table.php diff --git a/backend/db/blueprint.sql b/backend/db/blueprint.sql new file mode 100644 index 0000000..43956dc --- /dev/null +++ b/backend/db/blueprint.sql @@ -0,0 +1,30 @@ +CREATE TABLE IF NOT EXISTS `stores` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `parent_id` INT DEFAULT NULL, + `name` VARCHAR(255) NOT NULL, + FOREIGN KEY (`parent_id`) REFERENCES `stores`(`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `employees` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `store_id` INT NOT NULL, -- INT に修正 + `name` VARCHAR(255) NOT NULL, + FOREIGN KEY (`store_id`) REFERENCES `stores`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `customers` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `user_id` BIGINT NOT NULL, + `paid` BOOLEAN NOT NULL DEFAULT FALSE, + UNIQUE KEY `uk_user_id` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `histories` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `customer_user_id` BIGINT NOT NULL, + `store_id` INT NOT NULL, + `score` INT NOT NULL, + `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`customer_user_id`) REFERENCES `customers`(`user_id`) ON DELETE CASCADE, + FOREIGN KEY (`store_id`) REFERENCES `stores`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file diff --git a/backend/db/migrations/20260730124014_create_stores_table.php b/backend/db/migrations/20260730124014_create_stores_table.php new file mode 100644 index 0000000..2be94a5 --- /dev/null +++ b/backend/db/migrations/20260730124014_create_stores_table.php @@ -0,0 +1,28 @@ +table('stores'); + $table->addColumn('parent_id', 'integer', ['null' => true, 'default' => null]) + ->addColumn('name', 'string', ['limit' => 255, 'null' => false]) + ->addForeignKey('parent_id', 'stores', 'id', ['delete' => 'SET_NULL', 'update' => 'NO_ACTION']) + ->create(); + } +} diff --git a/backend/db/migrations/20260730124217_create_employees_table.php b/backend/db/migrations/20260730124217_create_employees_table.php new file mode 100644 index 0000000..4df8739 --- /dev/null +++ b/backend/db/migrations/20260730124217_create_employees_table.php @@ -0,0 +1,28 @@ +table('employees'); + $table->addColumn('store_id', 'integer', ['null' => false]) // integerに変更 + ->addColumn('name', 'string', ['limit' => 255, 'null' => false]) + ->addForeignKey('store_id', 'stores', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']) + ->create(); + } +} diff --git a/backend/db/migrations/20260730124354_create_customers_table.php b/backend/db/migrations/20260730124354_create_customers_table.php new file mode 100644 index 0000000..6224b3d --- /dev/null +++ b/backend/db/migrations/20260730124354_create_customers_table.php @@ -0,0 +1,28 @@ +table('customers'); + $table->addColumn('user_id', 'biginteger', ['null' => false]) + ->addColumn('paid', 'boolean', ['null' => false, 'default' => false]) + ->addIndex(['user_id'], ['unique' => true]) + ->create(); + } +} diff --git a/backend/db/migrations/20260730124432_create_histories_table.php b/backend/db/migrations/20260730124432_create_histories_table.php new file mode 100644 index 0000000..868eea9 --- /dev/null +++ b/backend/db/migrations/20260730124432_create_histories_table.php @@ -0,0 +1,33 @@ +table('histories'); + $table->addColumn('customer_user_id', 'biginteger', ['null' => false]) + ->addColumn('store_id', 'integer', ['null' => false]) + ->addColumn('score', 'integer', ['null' => false]) + ->addColumn('time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']) + ->addForeignKey('customer_user_id', 'customers', 'user_id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']) + ->addForeignKey('store_id', 'stores', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']) + ->addIndex(['customer_user_id', 'time']) + ->addIndex(['store_id', 'time']) + ->create(); + } +} From 4e37969f6e072d4a0cc23970c40c3380cd8bd066 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Thu, 30 Jul 2026 22:36:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/db/blueprint.sql | 7 ++++--- .../db/migrations/20260730124014_create_stores_table.php | 6 ++++-- .../migrations/20260730124217_create_employees_table.php | 2 +- .../migrations/20260730124354_create_customers_table.php | 1 + .../migrations/20260730124432_create_histories_table.php | 6 +++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/db/blueprint.sql b/backend/db/blueprint.sql index 43956dc..749f1eb 100644 --- a/backend/db/blueprint.sql +++ b/backend/db/blueprint.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS `stores` ( CREATE TABLE IF NOT EXISTS `employees` ( `id` INT AUTO_INCREMENT PRIMARY KEY, - `store_id` INT NOT NULL, -- INT に修正 + `store_id` INT NOT NULL, `name` VARCHAR(255) NOT NULL, FOREIGN KEY (`store_id`) REFERENCES `stores`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS `customers` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `user_id` BIGINT NOT NULL, `paid` BOOLEAN NOT NULL DEFAULT FALSE, + `disabled` BOOLEAN NOT NULL DEFAULT FALSE, -- ゲーム終了時 true UNIQUE KEY `uk_user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -25,6 +26,6 @@ CREATE TABLE IF NOT EXISTS `histories` ( `store_id` INT NOT NULL, `score` INT NOT NULL, `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY (`customer_user_id`) REFERENCES `customers`(`user_id`) ON DELETE CASCADE, - FOREIGN KEY (`store_id`) REFERENCES `stores`(`id`) ON DELETE CASCADE + FOREIGN KEY (`customer_user_id`) REFERENCES `customers`(`user_id`) ON DELETE NO ACTION + FOREIGN KEY (`store_id`) REFERENCES `stores`(`id`) ON DELETE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file diff --git a/backend/db/migrations/20260730124014_create_stores_table.php b/backend/db/migrations/20260730124014_create_stores_table.php index 2be94a5..8c7247f 100644 --- a/backend/db/migrations/20260730124014_create_stores_table.php +++ b/backend/db/migrations/20260730124014_create_stores_table.php @@ -20,9 +20,11 @@ final class CreateStoresTable extends AbstractMigration public function change(): void { $table = $this->table('stores'); - $table->addColumn('parent_id', 'integer', ['null' => true, 'default' => null]) + $table->addColumn('parent_id', 'integer', ['null' => true, 'default' => null, 'signed'=> false]) ->addColumn('name', 'string', ['limit' => 255, 'null' => false]) - ->addForeignKey('parent_id', 'stores', 'id', ['delete' => 'SET_NULL', 'update' => 'NO_ACTION']) ->create(); + + $table->addForeignKey('parent_id', 'stores', 'id', ['delete' => 'SET_NULL', 'update' => 'NO_ACTION']) + ->update(); } } diff --git a/backend/db/migrations/20260730124217_create_employees_table.php b/backend/db/migrations/20260730124217_create_employees_table.php index 4df8739..6169bec 100644 --- a/backend/db/migrations/20260730124217_create_employees_table.php +++ b/backend/db/migrations/20260730124217_create_employees_table.php @@ -20,7 +20,7 @@ final class CreateEmployeesTable extends AbstractMigration public function change(): void { $table = $this->table('employees'); - $table->addColumn('store_id', 'integer', ['null' => false]) // integerに変更 + $table->addColumn('store_id', 'integer', ['null' => false, 'signed'=>false]) // integerに変更 ->addColumn('name', 'string', ['limit' => 255, 'null' => false]) ->addForeignKey('store_id', 'stores', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']) ->create(); diff --git a/backend/db/migrations/20260730124354_create_customers_table.php b/backend/db/migrations/20260730124354_create_customers_table.php index 6224b3d..4745538 100644 --- a/backend/db/migrations/20260730124354_create_customers_table.php +++ b/backend/db/migrations/20260730124354_create_customers_table.php @@ -22,6 +22,7 @@ public function change(): void $table = $this->table('customers'); $table->addColumn('user_id', 'biginteger', ['null' => false]) ->addColumn('paid', 'boolean', ['null' => false, 'default' => false]) + ->addColumn('disabled', 'boolean', ['null' => false, 'default' => false]) ->addIndex(['user_id'], ['unique' => true]) ->create(); } diff --git a/backend/db/migrations/20260730124432_create_histories_table.php b/backend/db/migrations/20260730124432_create_histories_table.php index 868eea9..bcb5ed4 100644 --- a/backend/db/migrations/20260730124432_create_histories_table.php +++ b/backend/db/migrations/20260730124432_create_histories_table.php @@ -21,11 +21,11 @@ public function change(): void { $table = $this->table('histories'); $table->addColumn('customer_user_id', 'biginteger', ['null' => false]) - ->addColumn('store_id', 'integer', ['null' => false]) + ->addColumn('store_id', 'integer', ['null' => false, 'signed'=>false]) ->addColumn('score', 'integer', ['null' => false]) ->addColumn('time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']) - ->addForeignKey('customer_user_id', 'customers', 'user_id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']) - ->addForeignKey('store_id', 'stores', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION']) + ->addForeignKey('customer_user_id', 'customers', 'user_id', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) + ->addForeignKey('store_id', 'stores', 'id', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) ->addIndex(['customer_user_id', 'time']) ->addIndex(['store_id', 'time']) ->create(); From 1422a35b52aa9dbe9bfc3f7e29736eae71c8b405 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Thu, 30 Jul 2026 22:39:04 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E3=82=AB=E3=83=B3=E3=83=9E=E6=8A=9C?= =?UTF-8?q?=E3=81=91=E3=82=92=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=99?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/db/blueprint.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/db/blueprint.sql b/backend/db/blueprint.sql index 749f1eb..d74b773 100644 --- a/backend/db/blueprint.sql +++ b/backend/db/blueprint.sql @@ -26,6 +26,6 @@ CREATE TABLE IF NOT EXISTS `histories` ( `store_id` INT NOT NULL, `score` INT NOT NULL, `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY (`customer_user_id`) REFERENCES `customers`(`user_id`) ON DELETE NO ACTION + FOREIGN KEY (`customer_user_id`) REFERENCES `customers`(`user_id`) ON DELETE NO ACTION, FOREIGN KEY (`store_id`) REFERENCES `stores`(`id`) ON DELETE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file