From 516ff490908b9fc98dffda4fb2513c7c9639fb3d Mon Sep 17 00:00:00 2001 From: Abner Tudtud <114082473+enjinabner@users.noreply.github.com> Date: Thu, 17 Aug 2023 12:21:29 +0800 Subject: [PATCH] Improve performance (#28) --- .github/workflows/run_tests.yml | 5 +- database/schema/mysql-schema.sql | 439 ++++++++++++++++++++++ tests/Feature/GraphQL/TestCaseGraphQL.php | 3 +- tests/TestCase.php | 3 +- 4 files changed, 445 insertions(+), 5 deletions(-) create mode 100644 database/schema/mysql-schema.sql diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index a7b9a32..fd07b94 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -40,9 +40,8 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, gmp, intl, json, mysql, readline, sodium, bcmath + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, gmp, intl, json, mysql, readline, sodium, bcmath, pcov tools: composer:v2 - coverage: xdebug env: COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -67,7 +66,7 @@ jobs: - name: Execute tests run: | - XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always --coverage-clover coverage.xml + php -d pcov.enabled=1 ./vendor/bin/phpunit --colors=always --coverage-clover coverage.xml env: DB_HOST: 127.0.0.1:${{ job.services.mysql.ports[3306] }} DB_DATABASE: platform diff --git a/database/schema/mysql-schema.sql b/database/schema/mysql-schema.sql new file mode 100644 index 0000000..d596293 --- /dev/null +++ b/database/schema/mysql-schema.sql @@ -0,0 +1,439 @@ +/*!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 `attributes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `attributes` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `collection_id` bigint unsigned NOT NULL, + `token_id` bigint unsigned DEFAULT NULL, + `key` varchar(255) NOT NULL, + `value` text NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `attributes_collection_id_token_id_index` (`collection_id`,`token_id`), + KEY `attributes_collection_id_token_id_key_index` (`collection_id`,`token_id`,`key`), + KEY `attributes_collection_id_index` (`collection_id`), + KEY `attributes_token_id_index` (`token_id`), + CONSTRAINT `attributes_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `attributes_token_id_foreign` FOREIGN KEY (`token_id`) REFERENCES `tokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `beam_batches`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `beam_batches` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `beam_type` varchar(255) NOT NULL DEFAULT 'TRANSFER_TOKEN', + `completed_at` timestamp NULL DEFAULT NULL, + `processed_at` timestamp NULL DEFAULT NULL, + `transaction_id` bigint unsigned DEFAULT NULL, + `collection_chain_id` varchar(255) DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `beam_batches_completed_at_index` (`completed_at`), + KEY `beam_batches_processed_at_index` (`processed_at`), + KEY `beam_batches_transaction_id_index` (`transaction_id`), + KEY `beam_batches_collection_chain_id_index` (`collection_chain_id`), + CONSTRAINT `beam_batches_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `beam_claims`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `beam_claims` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `token_chain_id` varchar(255) DEFAULT NULL, + `collection_id` bigint unsigned NOT NULL, + `beam_id` bigint unsigned NOT NULL, + `wallet_public_key` varchar(255) DEFAULT NULL, + `claimed_at` timestamp NULL DEFAULT NULL, + `state` varchar(255) DEFAULT NULL, + `code` varchar(255) DEFAULT NULL, + `nonce` int unsigned DEFAULT NULL, + `quantity` int unsigned NOT NULL DEFAULT '1', + `type` varchar(255) NOT NULL DEFAULT 'TRANSFER_TOKEN', + `attributes` json DEFAULT NULL, + `beam_batch_id` bigint unsigned DEFAULT NULL, + `ip_address` varchar(255) DEFAULT NULL, + `deleted_at` timestamp NULL DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `beam_claims_token_chain_id_index` (`token_chain_id`), + KEY `beam_claims_collection_id_index` (`collection_id`), + KEY `beam_claims_beam_id_index` (`beam_id`), + KEY `beam_claims_wallet_public_key_index` (`wallet_public_key`), + KEY `beam_claims_code_index` (`code`), + KEY `beam_claims_beam_batch_id_index` (`beam_batch_id`), + CONSTRAINT `beam_claims_beam_batch_id_foreign` FOREIGN KEY (`beam_batch_id`) REFERENCES `beam_batches` (`id`), + CONSTRAINT `beam_claims_beam_id_foreign` FOREIGN KEY (`beam_id`) REFERENCES `beams` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `beam_scans`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `beam_scans` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `beam_id` bigint unsigned NOT NULL, + `wallet_public_key` varchar(255) NOT NULL, + `message` varchar(255) NOT NULL, + `count` int unsigned NOT NULL DEFAULT '1', + `deleted_at` timestamp NULL DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `beam_scans_beam_id_index` (`beam_id`), + KEY `beam_scans_wallet_public_key_index` (`wallet_public_key`), + CONSTRAINT `beam_scans_beam_id_foreign` FOREIGN KEY (`beam_id`) REFERENCES `beams` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `beams`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `beams` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `description` varchar(1024) DEFAULT NULL, + `image` varchar(1024) DEFAULT NULL, + `start` datetime NOT NULL, + `end` datetime NOT NULL, + `collection_chain_id` varchar(255) NOT NULL, + `flags_mask` int unsigned NOT NULL DEFAULT '0', + `deleted_at` timestamp NULL DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `beams_code_unique` (`code`), + KEY `beams_collection_chain_id_index` (`collection_chain_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `blocks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `blocks` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `number` int NOT NULL, + `hash` varchar(255) DEFAULT NULL, + `synced` tinyint(1) NOT NULL DEFAULT '0', + `failed` tinyint(1) NOT NULL DEFAULT '0', + `exception` longtext, + `retried` tinyint(1) NOT NULL DEFAULT '0', + `events` longtext, + `extrinsics` longtext, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `blocks_number_unique` (`number`), + KEY `blocks_synced_index` (`synced`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `collection_account_approvals`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `collection_account_approvals` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `collection_account_id` bigint unsigned NOT NULL, + `wallet_id` bigint unsigned NOT NULL, + `expiration` int unsigned DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `collection_account_approvals_collection_account_id_index` (`collection_account_id`), + KEY `collection_account_approvals_wallet_id_index` (`wallet_id`), + CONSTRAINT `collection_account_approvals_collection_account_id_foreign` FOREIGN KEY (`collection_account_id`) REFERENCES `collection_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `collection_account_approvals_wallet_id_foreign` FOREIGN KEY (`wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `collection_accounts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `collection_accounts` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `wallet_id` bigint unsigned NOT NULL, + `collection_id` bigint unsigned NOT NULL, + `is_frozen` tinyint(1) NOT NULL DEFAULT '0', + `account_count` varchar(255) NOT NULL DEFAULT '0', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `collection_accounts_collection_id_wallet_id_index` (`collection_id`,`wallet_id`), + KEY `collection_accounts_wallet_id_index` (`wallet_id`), + KEY `collection_accounts_collection_id_index` (`collection_id`), + CONSTRAINT `collection_accounts_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `collection_accounts_wallet_id_foreign` FOREIGN KEY (`wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `collection_royalty_currencies`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `collection_royalty_currencies` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `collection_id` bigint unsigned NOT NULL, + `currency_collection_chain_id` varchar(255) NOT NULL, + `currency_token_chain_id` varchar(255) NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `collection_royalty_currencies_collection_id_index` (`collection_id`), + KEY `collection_royalty_currencies_currency_collection_chain_id_index` (`currency_collection_chain_id`), + KEY `collection_royalty_currencies_currency_token_chain_id_index` (`currency_token_chain_id`), + CONSTRAINT `collection_royalty_currencies_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `collections`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `collections` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `collection_chain_id` varchar(255) NOT NULL, + `owner_wallet_id` bigint unsigned NOT NULL, + `max_token_count` varchar(255) DEFAULT NULL, + `max_token_supply` varchar(255) DEFAULT NULL, + `force_single_mint` tinyint(1) NOT NULL DEFAULT '0', + `royalty_wallet_id` bigint unsigned DEFAULT NULL, + `royalty_percentage` double(8,2) DEFAULT NULL, + `is_frozen` tinyint(1) NOT NULL DEFAULT '0', + `token_count` varchar(255) NOT NULL DEFAULT '0', + `attribute_count` varchar(255) NOT NULL DEFAULT '0', + `total_deposit` varchar(255) NOT NULL DEFAULT '0', + `network` varchar(255) NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `collections_collection_chain_id_index` (`collection_chain_id`), + KEY `collections_owner_wallet_id_index` (`owner_wallet_id`), + KEY `collections_royalty_wallet_id_index` (`royalty_wallet_id`), + CONSTRAINT `collections_owner_wallet_id_foreign` FOREIGN KEY (`owner_wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `collections_royalty_wallet_id_foreign` FOREIGN KEY (`royalty_wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `events`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `events` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `transaction_id` bigint unsigned NOT NULL, + `phase` int NOT NULL, + `look_up` varchar(255) NOT NULL, + `module_id` varchar(255) NOT NULL, + `event_id` varchar(255) NOT NULL, + `params` text, + PRIMARY KEY (`id`), + KEY `events_module_id_event_id_index` (`module_id`,`event_id`), + KEY `events_transaction_id_index` (`transaction_id`), + KEY `events_module_id_index` (`module_id`), + KEY `events_event_id_index` (`event_id`), + CONSTRAINT `events_transaction_id_foreign` FOREIGN KEY (`transaction_id`) REFERENCES `transactions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_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) NOT NULL, + `batch` int NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `pending_events`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `pending_events` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `uuid` char(36) NOT NULL, + `name` varchar(255) NOT NULL, + `sent` timestamp NOT NULL, + `channels` json NOT NULL, + `data` json NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `pending_events_uuid_unique` (`uuid`), + KEY `pending_events_name_index` (`name`), + KEY `pending_events_sent_index` (`sent`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `token_account_approvals`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_account_approvals` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `token_account_id` bigint unsigned NOT NULL, + `wallet_id` bigint unsigned NOT NULL, + `amount` varchar(255) NOT NULL DEFAULT '0', + `expiration` int unsigned DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `token_account_approvals_token_account_id_index` (`token_account_id`), + KEY `token_account_approvals_wallet_id_index` (`wallet_id`), + CONSTRAINT `token_account_approvals_token_account_id_foreign` FOREIGN KEY (`token_account_id`) REFERENCES `token_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `token_account_approvals_wallet_id_foreign` FOREIGN KEY (`wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `token_account_named_reserves`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_account_named_reserves` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `token_account_id` bigint unsigned NOT NULL, + `pallet` varchar(255) NOT NULL, + `amount` varchar(255) NOT NULL DEFAULT '0', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `token_account_named_reserves_token_account_id_index` (`token_account_id`), + CONSTRAINT `token_account_named_reserves_token_account_id_foreign` FOREIGN KEY (`token_account_id`) REFERENCES `token_accounts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `token_accounts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `token_accounts` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `wallet_id` bigint unsigned NOT NULL, + `collection_id` bigint unsigned NOT NULL, + `token_id` bigint unsigned NOT NULL, + `balance` varchar(255) NOT NULL DEFAULT '1', + `reserved_balance` varchar(255) NOT NULL DEFAULT '0', + `is_frozen` tinyint(1) NOT NULL DEFAULT '0', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `token_accounts_wallet_id_collection_id_index` (`wallet_id`,`collection_id`), + KEY `token_accounts_wallet_id_collection_id_token_id_index` (`wallet_id`,`collection_id`,`token_id`), + KEY `token_accounts_wallet_id_index` (`wallet_id`), + KEY `token_accounts_collection_id_index` (`collection_id`), + KEY `token_accounts_token_id_index` (`token_id`), + CONSTRAINT `token_accounts_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `token_accounts_token_id_foreign` FOREIGN KEY (`token_id`) REFERENCES `tokens` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `token_accounts_wallet_id_foreign` FOREIGN KEY (`wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `tokens`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `tokens` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `collection_id` bigint unsigned NOT NULL, + `token_chain_id` varchar(255) NOT NULL, + `supply` varchar(255) NOT NULL DEFAULT '1', + `cap` varchar(255) NOT NULL, + `cap_supply` varchar(255) DEFAULT NULL, + `royalty_wallet_id` bigint unsigned DEFAULT NULL, + `royalty_percentage` double(8,2) DEFAULT NULL, + `is_currency` tinyint(1) NOT NULL DEFAULT '0', + `listing_forbidden` tinyint(1) NOT NULL DEFAULT '0', + `is_frozen` tinyint(1) NOT NULL DEFAULT '0', + `minimum_balance` varchar(255) NOT NULL DEFAULT '1', + `unit_price` varchar(255) NOT NULL DEFAULT '0', + `mint_deposit` varchar(255) NOT NULL DEFAULT '0', + `attribute_count` int NOT NULL DEFAULT '0', + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `tokens_collection_id_token_chain_id_index` (`collection_id`,`token_chain_id`), + KEY `tokens_collection_id_index` (`collection_id`), + KEY `tokens_token_chain_id_index` (`token_chain_id`), + KEY `tokens_royalty_wallet_id_index` (`royalty_wallet_id`), + CONSTRAINT `tokens_collection_id_foreign` FOREIGN KEY (`collection_id`) REFERENCES `collections` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `tokens_royalty_wallet_id_foreign` FOREIGN KEY (`royalty_wallet_id`) REFERENCES `wallets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `transactions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `transactions` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `idempotency_key` varchar(255) DEFAULT NULL, + `transaction_chain_id` varchar(255) DEFAULT NULL, + `transaction_chain_hash` varchar(255) DEFAULT NULL, + `wallet_public_key` char(70) NOT NULL, + `method` varchar(255) NOT NULL, + `state` char(15) NOT NULL DEFAULT 'PENDING', + `result` varchar(255) DEFAULT NULL, + `encoded_data` text, + `signed_at_block` int unsigned DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `transactions_idempotency_key_unique` (`idempotency_key`), + KEY `transactions_state_wallet_public_key_index` (`state`,`wallet_public_key`), + KEY `transactions_transaction_chain_hash_wallet_public_key_index` (`transaction_chain_hash`,`wallet_public_key`), + KEY `transactions_transaction_chain_id_index` (`transaction_chain_id`), + KEY `transactions_wallet_public_key_index` (`wallet_public_key`), + KEY `transactions_state_index` (`state`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `verifications`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `verifications` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `verification_id` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `public_key` varchar(255) DEFAULT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `verifications_verification_id_unique` (`verification_id`), + KEY `verifications_public_key_index` (`public_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `wallets`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `wallets` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `external_id` varchar(255) DEFAULT NULL, + `verification_id` varchar(255) DEFAULT NULL, + `public_key` varchar(255) DEFAULT NULL, + `managed` tinyint(1) NOT NULL DEFAULT '0', + `network` varchar(255) NOT NULL, + `created_at` timestamp NULL DEFAULT NULL, + `updated_at` timestamp NULL DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `wallets_external_id_unique` (`external_id`), + UNIQUE KEY `wallets_verification_id_unique` (`verification_id`), + UNIQUE KEY `wallets_public_key_unique` (`public_key`), + KEY `wallets_managed_public_key_index` (`managed`,`public_key`), + KEY `wallets_managed_index` (`managed`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_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` VALUES (1,'2022_04_09_120404_create_wallets_table',1); +INSERT INTO `migrations` VALUES (2,'2022_04_09_120405_create_collections_table',1); +INSERT INTO `migrations` VALUES (3,'2022_04_09_120406_create_collection_accounts_table',1); +INSERT INTO `migrations` VALUES (4,'2022_04_09_120407_create_tokens_table',1); +INSERT INTO `migrations` VALUES (5,'2022_04_09_120408_create_token_accounts_table',1); +INSERT INTO `migrations` VALUES (6,'2022_04_09_120409_create_attributes_table',1); +INSERT INTO `migrations` VALUES (7,'2022_04_09_120410_create_blocks_table',1); +INSERT INTO `migrations` VALUES (8,'2022_04_09_120411_create_transactions_table',1); +INSERT INTO `migrations` VALUES (9,'2022_05_26_101200_create_verifications_table',1); +INSERT INTO `migrations` VALUES (10,'2022_06_19_103015_create_token_account_approvals_table',1); +INSERT INTO `migrations` VALUES (11,'2022_06_19_144041_create_token_account_named_reserves_table',1); +INSERT INTO `migrations` VALUES (12,'2022_06_19_152115_create_collection_account_approvals_table',1); +INSERT INTO `migrations` VALUES (13,'2022_09_14_144041_create_collection_royalty_currencies_table',1); +INSERT INTO `migrations` VALUES (14,'2022_10_11_141639_create_beam_batches_table',1); +INSERT INTO `migrations` VALUES (15,'2022_10_12_115527_create_beams_table',1); +INSERT INTO `migrations` VALUES (16,'2022_10_12_115558_create_beam_claims_table',1); +INSERT INTO `migrations` VALUES (17,'2022_10_17_143652_create_beam_scans_table',1); +INSERT INTO `migrations` VALUES (18,'2022_10_22_131819_create_events_table',1); +INSERT INTO `migrations` VALUES (19,'2023_02_03_135022_create_pending_events_table',1); +INSERT INTO `migrations` VALUES (20,'2023_03_20_204012_add_signed_at_block',1); +INSERT INTO `migrations` VALUES (21,'2023_05_23_034339_remove_link_code_from_wallets_table',1); +INSERT INTO `migrations` VALUES (22,'2023_06_27_014433_add_collection_chain_id_to_beam_batches_table',1); diff --git a/tests/Feature/GraphQL/TestCaseGraphQL.php b/tests/Feature/GraphQL/TestCaseGraphQL.php index fdf5f71..113196f 100644 --- a/tests/Feature/GraphQL/TestCaseGraphQL.php +++ b/tests/Feature/GraphQL/TestCaseGraphQL.php @@ -184,10 +184,11 @@ protected function defineEnvironment($app): void $app['config']->set('database.default', env('DB_DRIVER', 'mysql')); $app['config']->set('database.connections.mysql', [ 'driver' => 'mysql', - 'host' => env('DB_HOST', '127.0.0.1:3306'), + 'host' => env('DB_HOST', '127.0.0.1'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', 'password'), 'database' => env('DB_DATABASE', 'platform'), + 'port' => env('DB_PORT', '3306'), 'prefix' => '', ]); diff --git a/tests/TestCase.php b/tests/TestCase.php index 4ac94a0..d67b78c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -44,10 +44,11 @@ protected function defineEnvironment($app) // MySQL config $app['config']->set('database.connections.mysql', [ 'driver' => 'mysql', - 'host' => env('DB_HOST', '127.0.0.1:3306'), + 'host' => env('DB_HOST', '127.0.0.1'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', 'password'), 'database' => env('DB_DATABASE', 'platform'), + 'port' => env('DB_PORT', '3306'), 'prefix' => '', ]);