Upgrading the Database
Yarkon by default comes with a SQLite database that is bundled with any standard deployment of Yarkon Server and Yarkon Docker. Other databases that are supported are MySQL, AWS Aurora (compatible with MySQL) and PostgreSQL.
Schema files
The be able to set up a new deployment of Yarkon or to upgrade an existing one, you'd need the database schema files. On a Yarkon Server AMI or Yarkon Docker container, the schema files are located under the root Yarkon folder - /var/app/curr
, in the folder /migrations/<database name>
, and is named 0.0.0.sql
. So for instance, for MySQL, the file would have the path /var/app/curr/migrations/mysql/0.0.0.sql
.
Deploying a new Schema
To create a new Yarkon schema, use the aformentioned file and execute it as-is. Note that by default, the schema created would be named aphek
, so if you prefer a different name, edit the file first. For instance, when using MySQL, you'd need to change the first couple of lines like so:
CREATE DATABASE IF NOT EXISTS `my_database_name` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `my_database_name`;
Upgrading an Existing Schema
Any time you upgrade to a new version of Yarkon, the database schema might need to be updated.
There is more than one method to upgrade the schema. We recommend the following steps:
- Create a clone of your current database, it will be used as the starting point.
- Use the following procedure to upgrade that clone (see below, "Upgrading a Database In-Place").
- Test it with the new version of Yarkon.
- Once confirmed, either replace the existing database with the now upgraded clone, or repoing the connection string to point to the new database schema. See
DATABASE_HOST
in Environment Variables.
Upgrading a Database In-Place
The starting point is a clone of your current database, so all data is present.
- Use the
0.0.0.sql
file that came with the new version of Yarkon you are about to deploy. - Fetch the file that was used to create your current database schema. If you used this guide, you saved it in a safe place. If you do not have it, you can either get it from the AMI (or docker container) used for your previous install, or contact us.
- Run a diff of the two files. This will tell you what has changed. If nothing changed, you can stop here. If there are changes, proceed.
- Using your favorite SQL interface, run all changes. This should complete the migration.
- Save the
0.0.0.sql
file in a safe place. You'd need it for the next upgrade.