Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Grouparoo can use SQLite #965

Merged
merged 21 commits into from Nov 11, 2020
Merged

Grouparoo can use SQLite #965

merged 21 commits into from Nov 11, 2020

Conversation

evantahler
Copy link
Member

@evantahler evantahler commented Nov 10, 2020

This PR makes it possible to run Grouparoo against a SQLite database. This enables both in-memory operation and persisting the SQLite database to disk. Per #935, this will make it easier to get started with Grouparoo.

Features

  • With the first-time developer experience in mind, this PR changes the output of grouparoo generate to use SQLite by default
  • This PR removes any custom queries which would only work on Postgres
  • This PR removes any custom aggregations that only work on Postgres (or knows how to format things for both PG and SQLite)
  • This PR removes all instances of findOrCreate globally in the app... they keep causing problems!
  • Re run (some) tests in CI against sqlite

Questions

  • SQLite does not like the creation of new records in @afterSave/@afterCreate hooks. This makes the LoggedModel hard to use. We can choose to not await these, so they will be outside of the save transaction... but then we can't guarantee that the logs are written... See 1cbe2ac for more info
  • Hooks which add or create models (like using an @afterSave to create a Log record) need to use the transaction of the parent model, if there is a transaction in play. SQLite only has one transaction available, so can't await Log.create() in a hook without the transaction... it will never complete.
  • iLike (case-insensitive like queries) do not work for sqlite. - there are now a few conditionals scattered about the codebase based on config.sequelize.dialect

Part of #935
Closes T-673

@evantahler evantahler added the enhancement New feature or request label Nov 10, 2020
@height
Copy link

height bot commented Nov 10, 2020

This pull request has been linked to and will mark 1 task as "Delivered" when merged:

💡Tip: You can link multiple Height tasks to a pull request.

@evantahler evantahler added the BLOCKED do not merge label Nov 10, 2020
@evantahler
Copy link
Member Author

This PR is blocked by sequelize/sequelize#12823

@evantahler evantahler changed the title Grouparoo can use Sqlite Grouparoo can use SQLite Nov 10, 2020
@evantahler
Copy link
Member Author

We can work around sequelize/sequelize#12823 by changing our migrations to include a default value for non-null columns in one migration. See 5c1bb1b for more info

@evantahler evantahler marked this pull request as ready for review November 10, 2020 23:56
@evantahler evantahler merged commit deb69b2 into master Nov 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
BLOCKED do not merge enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Grouparoo can be run locally without Postgres or Redis
1 participant