DEV Community

RPScripts
RPScripts

Posted on

FiveM Script Database Migrations: What to Check Before You Install

Most FiveM script problems that show up a week after the install are not script bugs. They are database problems, and they are the reason a resource that looked perfect in the demo behaves strangely on your server.

Every serious FiveM script stores something: a player's job, a vehicle's fuel level, a business balance, a phone contact list. The question is what it does to your database before it does that, and whether it can undo it.

Three things a script can do to your database

1. Create tables. A lot of scripts create their own tables on first start, usually with a name prefix such as scriptname_ or esx_. This is convenient and it is also the reason two scripts can fight: if two packages use the same table name with different columns, the second install silently wins and the first script starts throwing "unknown column" errors.

2. Require you to import SQL. Older and more professional scripts ship a .sql file and expect you to import it. Read the file before importing. The important lines are the CREATE TABLE and ALTER TABLE statements, because they tell you exactly what the script expects to exist.

3. Migrate existing rows. This is the one that hurts. A script that updates its schema on start might run an UPDATE across your player table, for example when a job was renamed from police to lspd. On a fresh demo server that is invisible. On your live server it can rewrite data for hundreds of players while you are reading this sentence.

The check that takes two minutes

Before you install anything, ask three questions:

  • Does the script create tables, import SQL, or modify existing ones?
  • Does it use a table name that another script on your server might also use?
  • Does it need a database user with write access to tables it does not own?

If the answer to the third question is yes, run it on a separate database first. A dedicated test database is the cheapest insurance in FiveM: export your current one, import it into a second schema, point the test server at the copy and install there. If the script breaks the copy, it breaks nothing that matters.

Reading the error instead of guessing

When a script fails after the install, the console usually names the problem directly:

  • Unknown column 'x' in 'field list' — the table exists but the schema is older than the script expects. Import the newer SQL file or update the column.
  • Table 'x' doesn't exist — the script expected you to import SQL and did not find it.
  • Duplicate entry for a unique key — the script is trying to create a row that already exists, often because it ran twice during a failed start.

The static checker in the FiveM script tester catches the file-level problems before install, and the resource catalogue is separated per framework in all scripts, so you can compare what a package expects against what your server already runs.

A short checklist before you press install

  • Read the SQL, if there is any, and note every table name.
  • Check those table names against the scripts you already run.
  • Test the install on a copy of the database, not on the live one.
  • Keep the export from before the install. Restoring a schema takes seconds; rebuilding lost data does not.
  • Pair the install with a correct load order in your server.cfg, because a script that starts before its framework will fail on the first query it sends.

None of this is complicated. It is just easier to do before the install than after the first support ticket.

Top comments (0)