benswift

benswift

Hey team

I’m building a new ash phoenix app with a sqlite3* backend (everything up-to-date, mix hex-outdated shows all green). Because I’m early in the development process my resources are changing a lot as I “explore the domain”.

I keep running into issues where the auto-generated migrations (i.e. mix ash_sqlite.generate_migrations) try and do things which would work fine in postgres but don’t work in sqlite3 (here’s one example, but I’ve run into a few different similar scenarios).

My current workflow is to

  1. sigh heavily
  2. delete all the migrations and resource_snapshots in the app
  3. mix ecto.reset
  4. start again with a new mix ash_sqlite.generate_migrations

It’s kindof cheating, but since I’m still early in the development (nothing deployed to prod yet) I can get away with it.

I can think of a few ways I could do things differently:

  1. modify the generated migrations to use the various workarounds required to make sqlite3 actually do the things (may require executeing a bunch of raw SQL in the migrations, but I’m ok with that)
  2. modify the generate_migrations task so that it automatically applies the workarounds (happy to contribute these upstream, too - but I’m not sure how robust the detection will be and I’m not sure you wanna go down the “apply hacky workarounds” path with ash_sqlite)
  3. never make these breaking changes to the tables, and just work around things in app code (might be necessary in an existing app which can’t tolerate the downtime, etc, but that’s not my situation - so I don’t want to go down this path)
  4. switch to postgres :wink:
  5. some other option I’m missing?

Anyway thanks heaps for all your work on Ash - it’s an amazing stack, and I don’t mean to complain. Just want to know the best way forward given my situation.

*why ash_sqlite? I’m working on several small “proof of concept” apps, none of which have “precious” data, and I love the ops simplicity of using sqlite. And although I haven’t heard much from the litefs crew recently I do like that idea (since my apps all on fly anyway). So I’d rather not take option #4, and given that `ash_sqlite_ is a thing I guess you want to provide the sqlite option.

First 5 of 5 Posts Switch mode

zachdaniel

zachdaniel

Creator of Ash

We basically just copied the migration generator from ash_postgres into the other data layers knowing full well that they would need to be tweaked, potentially significantly. Your options are essentially

  1. don’t use the migration generator, and handwrite migrations (not in like an aggressive way I just want to point out that it is absolutely an option to use hand-written migrations)
  2. PRs welcome on improvements to the migration generator. Even if it’s just emitting warnings saying “hey, you have to write this bit by hand because we can’t make that change automatically”, or if it’s applying various known workarounds.
  3. write a script that will at least make your life a bit easier by deleting those files and regenerating :laughing:

No magic fixes unfortunately, it’s just a truth that the sqlite/mysql data layers haven’t received even half as much love as ash_postgres. Not because we don’t care about them, they are just much newer and don’t have champions for getting their DX up to snuff w/ what ash_postgres offers. At Alembic we have tons of projects shipping using ash_postgres and its far and above our most used data layer, so it gets the most attention from me (for better or for worse :smile: )

benswift

benswift OP

Hey mate thanks for the quick response. And I completely understand your (and Alembic’s) postgres-first approach. Hi from Canberra, btw :slight_smile:

I think my plan is to do #1, but I am open to submitting PRs as per #2 - especially the “emit warning, with advice on potential workaround” thing. I’m a vaguely-competent db guy, but not a guru (my expertise lies elsewhere in the stack). So I’m reluctant to put myself forward as a go-to for tricky db workarounds, but I guess I can see what works for me and then make suggestions to see if they’ll work for others. IOW I might not be the champion you’re looking for, but I can possibly help a bit.

And I’ve actually done #3 already :wink: So I may just keep trundling along with that approach until I’ve actually shipped something.

zachdaniel

zachdaniel

Creator of Ash

What might be a great middle ground is if you could document in issues the various behaviors that bite you and the problems the caused. That way we can at minimum catalogue them :slight_smile:

benswift

benswift OP

Roger that, will do. I remember a while ago you recommended a single-file ash app thingy which was useful for creating reproducible errors. I’ll try and track that down.

joelpaulkoch

joelpaulkoch

Hi, I just want to add that this website has guides for some scenarios including " Using SQLite ALTER TABLE for other actions" (other than renaming) here: SQLite ALTER TABLE & How To Overcome Its Limitations

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

We're in Beta

About us Mission Statement