halvardssm / deno-nessie

A modular Deno library for PostgreSQL, MySQL, MariaDB and SQLite migrations
MIT License
527 stars 31 forks source link

[QUESTION] Getting started questions (e.g. Nessie & deps.ts, separate db configs, experimental classes, etc.) #81

Closed gaylonalfano closed 4 years ago

gaylonalfano commented 4 years ago

Your question Hi There -- I can break these questions into multiple if that would help. I have some beginner/starter questions for you if you don't mind.

Background: I already have a basic (very) Deno + Oak + Postgres project going. For example, in my application I have a custom config.ts file that pulls in my Postgres creds from a .env file. I also have a basic db.ts file that establishes a Postgres connection using these credentials.

After initializing Nessie following your docs, here are some questions that come to mind:

  1. Should I re-use my database configuration I already have inside my config.ts and db.ts? Or, is it better to keep Nessie and my application separate?

  2. When using Nessie, should I use my default "postgres" user or the "root" user like in your example?

  3. Related to my previous questions, in my db.ts file I use the deno-postgres query builder to perform some simple queries. Should I re-use it or configure Nessie to be totally separate? Just trying to understand what I can/cannot or should/should not re-use, generally speaking.

Thanks in advance for your help!

halvardssm commented 4 years ago

Hi @gaylonalfano ! Great that you are reaching out! Let me answer your questions one by one.

  1. I created the config with reusability in mind, which is why you can pass along the entire config from your db.ts folder (the config is simply passed onto the client).

  2. You can use whatever you want to use, or which users your database allows. (following the deno-postgres docs is probably the simplest).

  3. The thought behind Nessie is that it is modular, so you should be able to use whatever you want. If you are using the new experimental syntax (which I would recommend), you can access the native database client in the migration file. You can use any query builder you want to, as long as it is compatible with the client. Basically, Nessie is just an extention (wrapper) on top of the modules you will be using either way, thus should work with all of them.

Let me know if you have any other questions!

gaylonalfano commented 4 years ago

This is great and thank you for the quick reply! Glad to hear I can/should reuse my config where it makes sense.

Another related question:

I noticed that to execute Nessie CLI commands we have to point to the Nessie module URL. Normally we specify dependencies with the version, but is that necessary with Nessie? Deno complains a little when I do not specify the version, but I guess in Nessie's case, it's not a typical dependency I would add to, say, my deps.ts file.

Thank you again for clarifying!

halvardssm commented 4 years ago

Absolutely! Happy that you find this module useful!

Regarding Nessie, I am trying to keep to the semantic versioning as much as possible, but to be on the safe side (specially since these are database migrations), you should lock the version number or at least to the minor version (e.g. 1.1.0 or ~1.1.0)