🗃️SQL Installation

Once you extract the script from its compressed .ZIP file and open the folder, you will find a folder called [SQL], there you will find the code you will need to configure the script database.

  1. Prepare MySQL: Open your MySQL Database Management System and access your corresponding database.

  2. Add the line 'USE `esxlegacy_[id];`': Before pasting the SQL code block from the 'SQL.sql' file, make sure you are using the correct database. If your database has an 'esxlegacy_' prefix followed by some identifier, make sure you use that prefix followed by your identifier. For example, if your identifier is '123', the line should be USE `esxlegacy_123`;;.

  3. Paste the SQL code block: Copy the SQL code block from the 'job.sql' file and paste it into the MySQL Database Management System, ensuring the entire block is correctly selected.

  4. Execute the code: Execute the code. This will create the necessary tables and perform data insertions in your database.

  5. Verification: After executing the code, verify that the actions have been performed correctly. You can review the created tables and inserted data to ensure everything is in order.

Following these instructions, you should be able to effectively utilize the [SQL] folder of your FiveM script to perform the necessary actions in your MySQL database.

  `identifier` varchar(69) NOT NULL,
  `date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()

SQL Instructions Explained

The SQL command provided outlines the process of creating a new table within your MySQL database, specifically for the FiveM script context. Let's break down the components of this statement for a clearer understanding:

  • CREATE TABLE IF NOT EXISTS: This command initiates the creation of a table named dadi_rewards, only if it doesn't already exist in the database. This ensures that you won't receive an error if the table is already present, making the script idempotent.

  • Columns:

    • identifier: This column is defined to store a string with a maximum length of 69 characters. The NOT NULL constraint implies that every record must have an identifier value; it cannot be left empty.

    • date: This column is designed to store timestamp values. It is also set to NOT NULL, ensuring that a record cannot be created without a date. The default value for this column is the current timestamp when the record is inserted. Additionally, if any record in the table is updated, the date column will automatically update to the current timestamp due to the ON UPDATE current_timestamp() clause.

  • Table Options:

    • ENGINE = InnoDB: Specifies the storage engine for the table. InnoDB is a reliable choice that supports transactions, row-level locking, and foreign keys.

    • AUTO_INCREMENT = 1: This part of the statement is somewhat misleading in this context because our table does not have a column defined with the AUTO_INCREMENT attribute. Typically, this would be used with a primary key column to automatically generate a unique identifier for new records. You might want to revise the table structure if auto-incrementing behavior is desired.

    • DEFAULT CHARSET = latin1: Sets the default character set to latin1, which impacts how text is stored and retrieved. Depending on the data you expect to store, you might choose a different character set, like utf8mb4, to fully support Unicode including emoji and certain special characters.

Last updated