From 571106189a652d68b043ef631f294f9a2cc186cf Mon Sep 17 00:00:00 2001 From: Annika Backstrom Date: Thu, 30 May 2024 10:28:38 +0100 Subject: [PATCH] Re-do database schemas --- .../2024_05_29_200341_unique_bookmark_tag.php | 32 ---- .../2024_05_29_202010_bookmark_tag_table.php | 31 ---- ..._05_30_090534_create_job_batches_table.php | 35 +++++ ..._05_30_090542_create_failed_jobs_table.php | 32 ++++ .../2024_05_30_090544_create_jobs_table.php | 32 ++++ ...024_05_30_090551_create_sessions_table.php | 31 ++++ .../2024_05_30_090603_create_cache_table.php | 35 +++++ ...24_05_30_090816_create_urlsnail_tables.php | 53 +++++++ database/schema/mysql-schema.sql | 147 ++++++++++++++++++ 9 files changed, 365 insertions(+), 63 deletions(-) delete mode 100644 database/migrations/2024_05_29_200341_unique_bookmark_tag.php delete mode 100644 database/migrations/2024_05_29_202010_bookmark_tag_table.php create mode 100644 database/migrations/2024_05_30_090534_create_job_batches_table.php create mode 100644 database/migrations/2024_05_30_090542_create_failed_jobs_table.php create mode 100644 database/migrations/2024_05_30_090544_create_jobs_table.php create mode 100644 database/migrations/2024_05_30_090551_create_sessions_table.php create mode 100644 database/migrations/2024_05_30_090603_create_cache_table.php create mode 100644 database/migrations/2024_05_30_090816_create_urlsnail_tables.php create mode 100644 database/schema/mysql-schema.sql diff --git a/database/migrations/2024_05_29_200341_unique_bookmark_tag.php b/database/migrations/2024_05_29_200341_unique_bookmark_tag.php deleted file mode 100644 index b3491ce..0000000 --- a/database/migrations/2024_05_29_200341_unique_bookmark_tag.php +++ /dev/null @@ -1,32 +0,0 @@ -unique(['bookmark_id', 'tag_id']); - } - ); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table( - 'bookmarks_tags', function (Blueprint $table) { - $table->dropUnique('cache_bookmark_id_tag_id_unique'); - } - ); - } -}; diff --git a/database/migrations/2024_05_29_202010_bookmark_tag_table.php b/database/migrations/2024_05_29_202010_bookmark_tag_table.php deleted file mode 100644 index e213ae0..0000000 --- a/database/migrations/2024_05_29_202010_bookmark_tag_table.php +++ /dev/null @@ -1,31 +0,0 @@ -foreignId('bookmark_id'); - $table->foreignId('tag_id'); - $table->timestamps(); - $table->primary(['bookmark_id', 'tag_id']); - } - ); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::drop('bookmark_tag'); - } -}; diff --git a/database/migrations/2024_05_30_090534_create_job_batches_table.php b/database/migrations/2024_05_30_090534_create_job_batches_table.php new file mode 100644 index 0000000..50e38c2 --- /dev/null +++ b/database/migrations/2024_05_30_090534_create_job_batches_table.php @@ -0,0 +1,35 @@ +string('id')->primary(); + $table->string('name'); + $table->integer('total_jobs'); + $table->integer('pending_jobs'); + $table->integer('failed_jobs'); + $table->longText('failed_job_ids'); + $table->mediumText('options')->nullable(); + $table->integer('cancelled_at')->nullable(); + $table->integer('created_at'); + $table->integer('finished_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('job_batches'); + } +}; diff --git a/database/migrations/2024_05_30_090542_create_failed_jobs_table.php b/database/migrations/2024_05_30_090542_create_failed_jobs_table.php new file mode 100644 index 0000000..249da81 --- /dev/null +++ b/database/migrations/2024_05_30_090542_create_failed_jobs_table.php @@ -0,0 +1,32 @@ +id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('failed_jobs'); + } +}; diff --git a/database/migrations/2024_05_30_090544_create_jobs_table.php b/database/migrations/2024_05_30_090544_create_jobs_table.php new file mode 100644 index 0000000..6098d9b --- /dev/null +++ b/database/migrations/2024_05_30_090544_create_jobs_table.php @@ -0,0 +1,32 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('jobs'); + } +}; diff --git a/database/migrations/2024_05_30_090551_create_sessions_table.php b/database/migrations/2024_05_30_090551_create_sessions_table.php new file mode 100644 index 0000000..f60625b --- /dev/null +++ b/database/migrations/2024_05_30_090551_create_sessions_table.php @@ -0,0 +1,31 @@ +string('id')->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->string('ip_address', 45)->nullable(); + $table->text('user_agent')->nullable(); + $table->longText('payload'); + $table->integer('last_activity')->index(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('sessions'); + } +}; diff --git a/database/migrations/2024_05_30_090603_create_cache_table.php b/database/migrations/2024_05_30_090603_create_cache_table.php new file mode 100644 index 0000000..b9c106b --- /dev/null +++ b/database/migrations/2024_05_30_090603_create_cache_table.php @@ -0,0 +1,35 @@ +string('key')->primary(); + $table->mediumText('value'); + $table->integer('expiration'); + }); + + Schema::create('cache_locks', function (Blueprint $table) { + $table->string('key')->primary(); + $table->string('owner'); + $table->integer('expiration'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('cache'); + Schema::dropIfExists('cache_locks'); + } +}; diff --git a/database/migrations/2024_05_30_090816_create_urlsnail_tables.php b/database/migrations/2024_05_30_090816_create_urlsnail_tables.php new file mode 100644 index 0000000..a57cbc3 --- /dev/null +++ b/database/migrations/2024_05_30_090816_create_urlsnail_tables.php @@ -0,0 +1,53 @@ +id(); + $table->string('href', 4096); + $table->string('title', 1024); + $table->text('description'); + $table->timestamps(); + } + ); + + Schema::create( + 'tags', function (Blueprint $table) { + $table->id(); + $table->string('name', 255)->unique(); + $table->timestamps(); + } + ); + + Schema::create( + 'bookmark_tag', function (Blueprint $table) { + $table->foreignIdFor(Bookmark::class); + $table->foreignIdFor(Tag::class); + $table->primary(['bookmark_id', 'tag_id']); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('bookmarks'); + Schema::dropIfExists('tags'); + Schema::dropIfExists('bookmark_tag'); + } +}; diff --git a/database/schema/mysql-schema.sql b/database/schema/mysql-schema.sql new file mode 100644 index 0000000..78563a9 --- /dev/null +++ b/database/schema/mysql-schema.sql @@ -0,0 +1,147 @@ +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +DROP TABLE IF EXISTS `bookmark_tag`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `bookmark_tag` ( + `bookmark_id` bigint unsigned NOT NULL, + `tag_id` bigint unsigned NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`bookmark_id`,`tag_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `bookmarks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `bookmarks` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `href` varchar(4096) COLLATE utf8mb4_unicode_ci NOT NULL, + `title` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL, + `description` text COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cache`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `cache` ( + `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `value` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL, + `expiration` int NOT NULL, + PRIMARY KEY (`key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `cache_locks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `cache_locks` ( + `key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `owner` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `expiration` int NOT NULL, + PRIMARY KEY (`key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `failed_jobs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `failed_jobs` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `connection` text COLLATE utf8mb4_unicode_ci NOT NULL, + `queue` text COLLATE utf8mb4_unicode_ci NOT NULL, + `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, + `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL, + `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `job_batches`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `job_batches` ( + `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `total_jobs` int NOT NULL, + `pending_jobs` int NOT NULL, + `failed_jobs` int NOT NULL, + `failed_job_ids` longtext COLLATE utf8mb4_unicode_ci NOT NULL, + `options` mediumtext COLLATE utf8mb4_unicode_ci, + `cancelled_at` int DEFAULT NULL, + `created_at` int NOT NULL, + `finished_at` int DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `jobs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `jobs` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `queue` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, + `attempts` tinyint unsigned NOT NULL, + `reserved_at` int unsigned DEFAULT NULL, + `available_at` int unsigned NOT NULL, + `created_at` int unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `jobs_queue_index` (`queue`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `migrations`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `migrations` ( + `id` int unsigned NOT NULL AUTO_INCREMENT, + `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `batch` int NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `sessions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `sessions` ( + `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `user_id` bigint unsigned DEFAULT NULL, + `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `user_agent` text COLLATE utf8mb4_unicode_ci, + `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL, + `last_activity` int NOT NULL, + PRIMARY KEY (`id`), + KEY `sessions_user_id_index` (`user_id`), + KEY `sessions_last_activity_index` (`last_activity`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tags`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `tags` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `tags_name_unique` (`name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'2024_05_30_090534_create_job_batches_table',1); +INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (2,'2024_05_30_090542_create_failed_jobs_table',1); +INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (3,'2024_05_30_090544_create_jobs_table',1); +INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (4,'2024_05_30_090551_create_sessions_table',1); +INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (5,'2024_05_30_090603_create_cache_table',1); +INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (6,'2024_05_30_090816_create_urlsnail_tables',1);