implemented new DB core, referal system
This commit is contained in:
@@ -46,6 +46,12 @@ app:
|
||||
# Maximum number of batches to process per cleanup run
|
||||
max-batches-per-run: ${APP_SESSION_CLEANUP_MAX_BATCHES:20}
|
||||
|
||||
# GeoIP configuration
|
||||
# Set GEOIP_DB_PATH environment variable to use external file (recommended for production)
|
||||
# If not set, falls back to classpath:geoip/GeoLite2-Country.mmdb
|
||||
geoip:
|
||||
db-path: ${GEOIP_DB_PATH:}
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
-- Drop foreign key constraint from sessions table if it exists
|
||||
-- Find the foreign key name dynamically (MySQL auto-generates names like sessions_ibfk_1)
|
||||
SET @fk_name = NULL;
|
||||
SELECT CONSTRAINT_NAME INTO @fk_name
|
||||
FROM information_schema.TABLE_CONSTRAINTS
|
||||
WHERE CONSTRAINT_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'sessions'
|
||||
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
|
||||
LIMIT 1;
|
||||
|
||||
SET @sql = IF(@fk_name IS NOT NULL,
|
||||
CONCAT('ALTER TABLE sessions DROP FOREIGN KEY ', @fk_name),
|
||||
'DO 1');
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- Drop old users table
|
||||
DROP TABLE IF EXISTS users;
|
||||
|
||||
-- Create db_users_a table
|
||||
CREATE TABLE `db_users_a` (
|
||||
`id` int NOT NULL,
|
||||
`screen_name` varchar(75) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '-',
|
||||
`telegram_id` bigint UNSIGNED DEFAULT NULL,
|
||||
`telegram_name` varchar(33) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '-',
|
||||
`is_premium` int NOT NULL DEFAULT '0',
|
||||
`language_code` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'XX',
|
||||
`country_code` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'XX',
|
||||
`device_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'XX',
|
||||
`ip` varbinary(16) DEFAULT NULL,
|
||||
`date_reg` int NOT NULL DEFAULT '0',
|
||||
`date_login` int NOT NULL DEFAULT '0',
|
||||
`banned` int NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- Create db_users_b table
|
||||
CREATE TABLE `db_users_b` (
|
||||
`id` int NOT NULL DEFAULT '0',
|
||||
`balance_a` bigint UNSIGNED NOT NULL DEFAULT '0',
|
||||
`balance_b` bigint UNSIGNED NOT NULL DEFAULT '0',
|
||||
`deposit_total` bigint NOT NULL DEFAULT '0',
|
||||
`deposit_count` int NOT NULL DEFAULT '0',
|
||||
`withdraw_total` bigint NOT NULL DEFAULT '0',
|
||||
`withdraw_count` int NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- Create db_users_d table
|
||||
CREATE TABLE `db_users_d` (
|
||||
`id` int NOT NULL DEFAULT '0',
|
||||
`referer_id_1` int NOT NULL DEFAULT '0',
|
||||
`referer_id_2` int NOT NULL DEFAULT '0',
|
||||
`referer_id_3` int NOT NULL DEFAULT '0',
|
||||
`referer_id_4` int NOT NULL DEFAULT '0',
|
||||
`referer_id_5` int NOT NULL DEFAULT '0',
|
||||
`master_id` int NOT NULL DEFAULT '0',
|
||||
`referals_1` int NOT NULL DEFAULT '0',
|
||||
`referals_2` int NOT NULL DEFAULT '0',
|
||||
`referals_3` int NOT NULL DEFAULT '0',
|
||||
`referals_4` int NOT NULL DEFAULT '0',
|
||||
`referals_5` int NOT NULL DEFAULT '0',
|
||||
`from_referals_1` bigint NOT NULL DEFAULT '0',
|
||||
`from_referals_2` bigint NOT NULL DEFAULT '0',
|
||||
`from_referals_3` bigint NOT NULL DEFAULT '0',
|
||||
`from_referals_4` bigint NOT NULL DEFAULT '0',
|
||||
`from_referals_5` bigint NOT NULL DEFAULT '0',
|
||||
`to_referer_1` bigint NOT NULL DEFAULT '0',
|
||||
`to_referer_2` bigint NOT NULL DEFAULT '0',
|
||||
`to_referer_3` bigint NOT NULL DEFAULT '0',
|
||||
`to_referer_4` bigint NOT NULL DEFAULT '0',
|
||||
`to_referer_5` bigint NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- Add indexes for db_users_a
|
||||
ALTER TABLE `db_users_a`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD UNIQUE KEY `telegram_id` (`telegram_id`),
|
||||
ADD KEY `telegram_name` (`telegram_name`),
|
||||
ADD KEY `ip` (`ip`);
|
||||
|
||||
-- Add indexes for db_users_b
|
||||
ALTER TABLE `db_users_b`
|
||||
ADD KEY `id` (`id`);
|
||||
|
||||
-- Add indexes for db_users_d
|
||||
ALTER TABLE `db_users_d`
|
||||
ADD KEY `id` (`id`),
|
||||
ADD KEY `referer_id_1` (`referer_id_1`),
|
||||
ADD KEY `referer_id_2` (`referer_id_2`),
|
||||
ADD KEY `referer_id_3` (`referer_id_3`),
|
||||
ADD KEY `referer_id_4` (`referer_id_4`),
|
||||
ADD KEY `referer_id_5` (`referer_id_5`),
|
||||
ADD KEY `master_id` (`master_id`);
|
||||
|
||||
-- Set auto increment for db_users_a
|
||||
ALTER TABLE `db_users_a`
|
||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
||||
|
||||
-- Update sessions table: change user_id from BIGINT to INT to match db_users_a.id
|
||||
ALTER TABLE `sessions`
|
||||
MODIFY `user_id` int NOT NULL;
|
||||
|
||||
-- Add foreign key constraint from sessions to db_users_a
|
||||
ALTER TABLE `sessions`
|
||||
ADD CONSTRAINT `fk_sessions_user_id` FOREIGN KEY (`user_id`) REFERENCES `db_users_a`(`id`) ON DELETE CASCADE;
|
||||
|
||||
BIN
src/main/resources/geoip/GeoLite2-Country.mmdb
Normal file
BIN
src/main/resources/geoip/GeoLite2-Country.mmdb
Normal file
Binary file not shown.
Reference in New Issue
Block a user