Database Migration: - Add MariaDB connection configuration and initialization (mariadb.js) - Create MariaDB schema update script (mariadb-schema-update.sql) - Add migration scripts for SQLite to MariaDB transition: * migrate-sqlite-to-mariadb.js: Main migration script * migrate-inventory-to-gear.js: Inventory schema migration - Remove SQLite-specific implementation files and databases Route Updates: - Update all route handlers to use MariaDB instead of SQLite - Migrate routes: playerRoutes, sessionRoutes, shopRoutes, bestiaryRoutes, rulesRoutes, rulesStagingRoutes, weaponsRoutes - Remove SQLite-specific route files (playerRoutes-sqlite.js, sessionRoutes-sqlite.js) - Update server.js to initialize MariaDB and register new weapon routes Backend Scripts: - Remove old SQLite migration scripts (migrate-to-sqlite.js, server-sqlite.js) - Delete obsolete database utility scripts from backup-scripts/ Frontend Updates: - Update logger utility for improved error handling and debugging - Enhance PlayerManagement component with better state management - Improve RequisitionShop component for MariaDB integration - Update DeathwatchRoller with performance improvements - Add login test suite (login.test.js) - Add XP progression utility (xpProgression.js) - Update dependencies in package.json and package-lock.json This migration improves: - Database scalability and performance - Transaction support for complex operations - Better data integrity and ACID compliance - Simplified deployment and backup procedures
97 lines
2.8 KiB
SQL
97 lines
2.8 KiB
SQL
-- Add missing tables to MariaDB schema
|
|
|
|
-- Shop items table
|
|
CREATE TABLE IF NOT EXISTS shop_items (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(255) NOT NULL UNIQUE,
|
|
category VARCHAR(100) NOT NULL,
|
|
requisition_cost INT NOT NULL DEFAULT 0,
|
|
renown_requirement VARCHAR(50) NOT NULL DEFAULT 'None',
|
|
item_type VARCHAR(100) NOT NULL,
|
|
stats TEXT NOT NULL,
|
|
source VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Player inventory table
|
|
CREATE TABLE IF NOT EXISTS player_inventory (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
player_id INT NOT NULL,
|
|
item_id INT NOT NULL,
|
|
quantity INT NOT NULL DEFAULT 1,
|
|
acquired_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
transaction_details TEXT,
|
|
FOREIGN KEY (player_id) REFERENCES players (id) ON DELETE CASCADE,
|
|
FOREIGN KEY (item_id) REFERENCES shop_items (id) ON DELETE CASCADE,
|
|
UNIQUE(player_id, item_id)
|
|
);
|
|
|
|
-- Transactions table
|
|
CREATE TABLE IF NOT EXISTS transactions (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
player_id INT NOT NULL,
|
|
item_id INT NOT NULL,
|
|
requisition_cost INT NOT NULL,
|
|
previous_rp INT NOT NULL,
|
|
new_rp INT NOT NULL,
|
|
transaction_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (player_id) REFERENCES players (id) ON DELETE CASCADE,
|
|
FOREIGN KEY (item_id) REFERENCES shop_items (id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Armour table
|
|
CREATE TABLE IF NOT EXISTS armour (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(255) UNIQUE NOT NULL,
|
|
req INT DEFAULT 0,
|
|
renown VARCHAR(50) DEFAULT 'None',
|
|
category VARCHAR(100),
|
|
stats TEXT,
|
|
source VARCHAR(255),
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Weapons table
|
|
CREATE TABLE IF NOT EXISTS weapons (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(255) UNIQUE NOT NULL,
|
|
req INT DEFAULT 0,
|
|
renown VARCHAR(50) DEFAULT 'None',
|
|
category VARCHAR(100),
|
|
stats TEXT,
|
|
source VARCHAR(255),
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Bestiary table
|
|
CREATE TABLE IF NOT EXISTS bestiary (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
name VARCHAR(255) NOT NULL,
|
|
book VARCHAR(255),
|
|
page VARCHAR(50),
|
|
pdf VARCHAR(255),
|
|
stats TEXT,
|
|
profile TEXT,
|
|
snippet TEXT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Rules table
|
|
CREATE TABLE IF NOT EXISTS rules (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
rule_id VARCHAR(255) UNIQUE,
|
|
title VARCHAR(500),
|
|
content TEXT,
|
|
page INT,
|
|
source VARCHAR(255),
|
|
source_abbr VARCHAR(50),
|
|
category VARCHAR(100),
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
-- Add missing columns to players table
|
|
ALTER TABLE players
|
|
ADD COLUMN IF NOT EXISTS requisition_points INT DEFAULT 0,
|
|
ADD COLUMN IF NOT EXISTS renown_level VARCHAR(50) DEFAULT 'None';
|