Describe the bug
On the Configuration page of the docs, the "2. A basic example of migrations folder" section is missing a description of what migrations are, both:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Migrations are explained
Screenshots
--
Desktop (please complete the following information):
Additional context
--
I think explaining terms such as "migrations" are a bit out of scope for SafeQL since I'm not trying to teach developers about SQL but rather give them a DX solution.
I believe the Configuration page should be as practical as possible. Although, I won't mind if there was a brief explanation (a sentence or two) about the topic with a follow-up to an FAQ page.
I think explaining terms such as "migrations" are a bit out of scope for SafeQL since I'm not trying to teach developers about SQL but rather give them a DX solution.
Ok, I just meant a single sentence about this, but I understand if you don't want to include this information.
I believe the Configuration page should be as practical as possible.
Totally agree! But the Configuration page should definitely have a description about what each thing does. Currently it is unexplained and undocumented - and as an experienced developer I still don't understand what this feature is, even after you wrote to me on Twitter about it
I see. Documentation was never my strong side. I'll try to be as descriptive as possible here, and maybe we can find a way to make it clearer in the docs:
I support two ways of analyzing the queries. Either by supplying a database URL or by migrations folder.
Schema migrations are a way of managing your database changes chronologically. Like Git, it helps track down how the database was built. It's the source of truth of your database declaration.
In other words, if you run your migrations against an empty schema, you'll get a database that represents the migrations folder.
Migration can have one or more statements (ALTER, CREATE, etc.). We run migrations like how we run queries.
Since we can't query against migration files (since they are only a set of instructions rather than an actual database), we need to create a database (we'll call it a shadow database) based on a set of instructions written in the migrations. Once we have a database, we can do what's written in the steps above.
Every time we decide we want to make a change in the migrations, we restart the ESLint server (or re-run in the terminal). Each time, it will drop (if it exists) the shadow database to avoid conflicts and recreate it (I want to improve this part, although it's pretty fast).
In other words, if we manually create a database based on the migrations folder and supply the database URL instead, if will work the same (until you decide to make some changes in the database or the migrations).
To create a database, we have to connect to Postgres. To connect to Postgres, we have to connect to an existing database. Which database will always exist? postgres
. That's why SafeQL requires supplying a connection URL. It also requires databaseName
, the "shadow database" that will be recreated and dropped every time. I have an open issue (#8) that will either simplify this step or make it more confusing.
Thanks!
I guess 2 things are still open for me here:
ley
or another arbitrary tool for my migrations? Can I write my migration files in TypeScript? Can I write my migration files in SQL?Owner Name | ts-safeql |
Repo Name | safeql |
Full Name | ts-safeql/safeql |
Language | TypeScript |
Created Date | 2022-09-08 |
Updated Date | 2023-03-16 |
Star Count | 795 |
Watcher Count | 5 |
Fork Count | 14 |
Issue Count | 7 |
Issue Title | Created Date | Updated Date |
---|