Create volume
name with your desired volume name. Only alphanumeric characters and underscores are allowed in names.
Optionally, you may specify the size of the volume, in gigabytes, by adding a --size int argument.
The default volume size is 3 gigabytes.
Mount and Prep for Deployment
Add the following to yourfly.toml, once again replacing the name with what you selected, this
time in two places:
[deploy] section of your fly.toml and add a DATABASE_PATH variable:
lib/name/application.ex:
Deploy
These changes can be deployed:Converting to SQLite3
Creating a new project with SQLite3 as the default is as simple as.gitignore to ignore SQLite database files:
:postgrex dep from your mix.exs with ecto_sqlite.
config/dev.exs:
config/test.exs:
DATABASE_URL in config/runtime.exs for production:
lib/name/repo.ex:
SQLite3 Tips
Limitations
Theecto_sqlite3 documentation includes a good guide on the limits of using Ecto with SQLite3. We recommend at least skimming this before putting it into production.
Transferring Data from Postgres/MySQL to SQLite3
This section is something to give you a starting point on how to get from X to SQLite. Make sure to back up your data and be vigilant, because this kind of thing is fraught at best.
This copies the table structure, table data, indexes, and foreign keys from the MySQL database to the PostgreSQL database.Note that the support for copying is fairly limited. It doesn’t handle database views, functions, triggers, schemas, partial indexes, functional indexes, and many other things. Also, the data type conversion may not be exactly what you want. It is best designed for quick conversions and testing. For serious production use, use the database’s tools to copy databases for the same database type, and for different database types, use the Sequel API.
macOS
Ubuntu
Note on types
SQLite doesn’t have official support for Postgres Arrays or Hstores, and most special datatypes! These will be copied into strings in the resulting SQLite table, so for Arrays the data will look like{item1, item2, item3} if you want to still use this as an array you need to use string manipulation to convert them to json and then it should work just fine. This is just one example, but the positive is that it’s all just strings in SQLite, so if you can make the string look like json you are set!
Copying an existing database to a fly volume
If you’ve exported or copied your database to SQLite you will need to get your database file up to Fly.io. To do this we will use the fly sftp command. First open an sftp shellput command to transfer your file to the volume path.
NOTE: Because our server is running, we first need to give the database a new name. Do not try to put this file in the same place as your current DATABASE_PATH.
volume_name corresponds to the name you used when creating your volume.
Check that it’s there:
ctrl-c to exit.
Finally, update your env in fly.toml:
Download a local copy of your production database
You can use the fly sftp get command to download your database locally./mnt/name/name-prod.db with the path to your database (DATABASE_PATH).