Database

How to connect JayCP to a database.

Jaycp.app is designed to work with a MySQL database. To connect the app to a database, you need to edit .env file in the root directory of the app. This file should contain the following information:

DB_HOST=localhost
DB_USER=root
DB_PASS=password
DB_NAME=database

Insert the connect information for the MTA:SA server database here.

Jaycp.app requires a seperate database to store data. Create the database by running this command in a mysql terminal.

CREATE DATABASE jaycp;

Once the database is created, you need to create its tables. You can import these from the attached .sql file or run the following commands:

CREATE TABLE `config` (
`configId` int NOT NULL DEFAULT '1' PRIMARY KEY AUTO_INCREMENT,
`TinyMCE_API_KEY` text NOT NULL,
`brandName` varchar(50) NOT NULL,
`shortBrandName` varchar(25) NOT NULL,
`serverIP` varchar(20) NOT NULL,
`serverPort` int NOT NULL,
`serverColor` varchar(15) NOT NULL,
`mainPanelColor` varchar(15) NOT NULL,
`secondaryPanelColor` varchar(15) NOT NULL,
`backgroundColor` varchar(15) NOT NULL,
`banColor` varchar(15) NOT NULL,
`jailColor` varchar(15) NOT NULL,
`banFrom` tinyint NOT NULL DEFAULT '1',
`jailFrom` tinyint NOT NULL DEFAULT '1',
`newsAccess` tinyint NOT NULL DEFAULT '1',
`couponAccess` tinyint NOT NULL DEFAULT '1',
`jailLogAccess` tinyint NOT NULL DEFAULT '1',
`vehLogAccess` tinyint NOT NULL DEFAULT '1',
`adminAccess` tinyint NOT NULL DEFAULT '1',
`nameAccess` tinyint NOT NULL DEFAULT '1',
`serialAccess` tinyint NOT NULL DEFAULT '1',
`accountAccess` tinyint NOT NULL DEFAULT '1',
`characterAccess` tinyint NOT NULL DEFAULT '1',
`banAccess` tinyint NOT NULL DEFAULT '1',
`settingsAccess` tinyint NOT NULL DEFAULT '1',
`profileAccess` tinyint NOT NULL DEFAULT '1',
`economyAccess` tinyint NOT NULL DEFAULT '1',
`sanctionDeleteAccess` tinyint NOT NULL DEFAULT '1',
`addAdminAccess` tinyint NOT NULL DEFAULT '1',
`adminStatsAccess` tinyint NOT NULL DEFAULT '1',
`currency` varchar(15) NOT NULL DEFAULT '$',
`navLogoURL` varchar(50),
`navItems` tinyint NOT NULL DEFAULT '2',
`link1Text` varchar(50),
`link1URL` varchar(50),
`link2Text` varchar(50),
`link2URL` varchar(50),
`link3Text` varchar(50),
`link3URL` varchar(50),
`link4Text` varchar(50),
`link4URL` varchar(50),
`SEOdescription` varchar(500),
`SEOkeywords` varchar(500),
`SMTP_HOST` varchar(100),
`SMTP_USER` varchar(100),
`SMTP_API_KEY` varchar(100),
`FROM_EMAIL` varchar(100),
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `config` VALUES (1,'','','','',0,'','','','','','','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','','','2','','','','','','','','','','','');

This table is used to store the configuration of the app.

CREATE TABLE `namerequests` (
`requestId` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` text NOT NULL,
`accountId` int NOT NULL,
`characterId` int NOT NULL,
`name` varchar(25) NOT NULL,
`newName` varchar(25) NOT NULL,
`reason` varchar(100) NOT NULL,
`status` varchar(20) NOT NULL DEFAULT 'Folyamatban',
`handledBy` varchar(20) DEFAULT NULL,
`handledAt` datetime DEFAULT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

This table is used to store name requests.

CREATE TABLE `news` (
`newsId` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`content` longtext CHARACTER SET utf8mb3 COLLATE utf8mb3_hungarian_ci NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`author` text CHARACTER SET utf8mb3 COLLATE utf8mb3_hungarian_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
TODO:insert def news

This table is used to store news.

CREATE TABLE `serialrequests` (
`requestId` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`accountId` int NOT NULL,
`username` varchar(20) NOT NULL,
`serial` varchar(50) NOT NULL,
`reason` varchar(100) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` varchar(20) NOT NULL DEFAULT 'Folyamatban',
`handledBy` varchar(20) DEFAULT NULL,
`handledAt` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

This table is used to store serial requests.

CREATE TABLE `password_reset` (
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`email` varchar(255) NOT NULL,
`token` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`used` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

This table is used to store password reset requests.

After creating the tables, you edit .env file in the root directory of the app and insert the jaycp.app database information. This file should contain the following information:

UCP_DB_HOST=localhost
UCP_DB_USER=root
UCP_DB_PASS=password
UCP_DB_NAME=jaycp