A simple JS script to migrate a local SQLite database to a Turso database on the cloud.
This project provides a straightforward JavaScript utility for migrating data from a local SQLite database to a Turso database hosted in the cloud. It leverages Node.js and a set of dependencies to facilitate the migration process, ensuring a seamless data transition from a local storage mechanism to a scalable, cloud-based solution.
Note
The migration of tables happens in parallel. If the table was not found on Turso, we used the SQL in the database/initial-table-creation.js
file to create it. If the the row already exists on Turso we update it with the local data.
- Easy configuration through environment variables.
- Automated migration of tables and data.
- Logging support for monitoring the migration process.
- Utilizes the
@libsql/client
for interacting with the Turso database. - Supports SQLite3 for local database interactions.
- Node.js installed on your machine.
- Access to a Turso database instance.
- Clone the repository:
git clone https://github.com/pferreirafabricio/sqlite-2-turso.git
- Install the dependencies:
cd sqlite-2-turso
npm install
- Configure your environment variables by copying the .env.example file to .env and filling in the necessary details:
cp .env.example .env
The migration script can be configured via environment variables. Here are the variables you can set:
SOURCE_DATABASE_PATH
: The path to your local SQLite database file.TURSO_DATABASE_URL
: The URL to your Turso database instance.TURSO_AUTH_TOKEN
: The authentication token for accessing your Turso database.SILENT
: Set to true to reduce logging verbosity.
To start the migration process, run:
npm run migrate
This project is licensed under the MIT License - see the LICENSE file for details.