Skip to content

Commit

Permalink
fix(database): use native MariaDB support and UUID type
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenrikur committed Feb 13, 2025
1 parent 40ef671 commit 006ed26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 55 deletions.
32 changes: 10 additions & 22 deletions config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,22 @@
]) : [],
],

'pgsql' => [
'driver' => 'pgsql',
'mariadb' => [
'driver' => 'mariadb',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'public',
'sslmode' => 'prefer',
],

'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
'strict' => true,
'engine' => null,
'options' => [],
],

],
Expand Down Expand Up @@ -125,7 +113,7 @@

'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
],

'default' => [
Expand Down
44 changes: 11 additions & 33 deletions database/schema/mariadb-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ DROP TABLE IF EXISTS `applications`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `applications` (
`id` char(36) NOT NULL,
`user_id` char(36) NOT NULL,
`id` UUID NOT NULL,
`user_id` UUID NOT NULL,
`table_type_requested` bigint(20) unsigned DEFAULT NULL,
`table_type_assigned` bigint(20) unsigned DEFAULT NULL,
`type` varchar(255) NOT NULL,
`parent_id` char(36) DEFAULT NULL,
`parent_id` UUID DEFAULT NULL,
`display_name` varchar(255) DEFAULT NULL,
`website` varchar(255) DEFAULT NULL,
`table_number` varchar(255) DEFAULT NULL,
Expand Down Expand Up @@ -66,13 +66,14 @@ DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comments` (
`uuid` char(36) NOT NULL,
`user_id` char(36) NOT NULL,
`application_id` char(36) NOT NULL,
`uuid` UUID NOT NULL,
`user_id` UUID NOT NULL,
`application_id` UUID NOT NULL,
`text` text NOT NULL,
`admin_only` tinyint(1) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`uuid`),
KEY `comments_user_id_foreign` (`user_id`),
KEY `comments_application_id_foreign` (`application_id`),
CONSTRAINT `comments_application_id_foreign` FOREIGN KEY (`application_id`) REFERENCES `applications` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
Expand All @@ -98,7 +99,7 @@ DROP TABLE IF EXISTS `keyword_profile`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `keyword_profile` (
`profile_id` char(36) NOT NULL,
`profile_id` UUID NOT NULL,
`keyword_id` bigint(20) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
Expand Down Expand Up @@ -138,8 +139,8 @@ DROP TABLE IF EXISTS `profiles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `profiles` (
`id` char(36) NOT NULL,
`application_id` char(36) DEFAULT NULL,
`id` UUID NOT NULL,
`application_id` UUID DEFAULT NULL,
`short_desc` text DEFAULT NULL,
`artist_desc` text DEFAULT NULL,
`art_desc` text DEFAULT NULL,
Expand Down Expand Up @@ -184,7 +185,7 @@ DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` char(36) NOT NULL,
`id` UUID NOT NULL,
`reg_id` varchar(255) DEFAULT NULL,
`identity_id` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
Expand All @@ -201,26 +202,3 @@ CREATE TABLE `users` (
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

/*!999999\- enable the sandbox mode */
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'2014_10_12_000000_create_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (2,'2019_08_19_000000_create_failed_jobs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (3,'2019_12_14_000001_create_personal_access_tokens_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (4,'2023_02_28_211414_create_table_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (5,'2023_02_28_212504_create_applications_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (6,'2023_02_28_214535_create_profiles_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (7,'2023_05_03_204632_add_mail_status_to_application',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (8,'2023_05_03_213105_add_package_name_to_table_type',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (9,'2023_05_16_192248_remove_mail_status_is_notified_from_applications',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (10,'2023_08_07_194554_add_groups_to_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (11,'2023_08_08_000000_alter_users_groups_to_longtext',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (12,'2023_08_08_215547_create_comments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (13,'2023_08_09_222220_add_checked_out_status',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (14,'2023_08_13_135050_increase_comment_text_length',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (15,'2024_01_26_160127_recreate_categories_keywords_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (16,'2024_01_26_201135_drop_profile_categories',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (17,'2024_01_29_222300_add_bluesky_mastodon_to_profile',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (18,'2024_01_30_001055_alter_application_invite_codes_to_unique',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (19,'2024_02_01_001244_add_is_hidden_to_profile',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (20,'2024_02_13_230449_alter_user_email_not_unique',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (21,'2024_02_18_125612_add_space_request_to_application',3);

0 comments on commit 006ed26

Please sign in to comment.