nitrictech / nitric

Nitric is a multi-language framework for cloud applications with infrastructure from code.
https://nitric.io
Apache License 2.0
1.17k stars 50 forks source link

AWS: SQL Resource - RDS MySQL Support #680

Open JustAndrew-pixel opened 2 months ago

JustAndrew-pixel commented 2 months ago

Feature Request

Suggestion

Add support for RDS MySQL databases and additional migrations mechanism

Value

For some use cases like "distributed data storage" it's better to use MySQL, instead of PostgreSQL DB. In that case it would be great to create RDS MySql with nitric code + supported migrations, without doing the same manually in AWS dashboard.

Alternatives

Other info

jyecusch commented 1 month ago

We probably want to consider allowing the resource request in the app code to specify the SQL dialect (since the app presumably relies on it).

For example, SQL like this is valid for Postgres, but not for MySQL:

CREATE TABLE items (
  id SERIAL PRIMARY KEY,
  in_stock BOOLEAN
);

MySQL would be something like this instead:

CREATE TABLE items (
  id INT AUTO_INCREMENT PRIMARY KEY,
  in_stock TINYINT(1)
);

A few proposals I can think of:

import { sql } from '@nitric/sdk'
// dialect param
const db = sql('my-database', 'MySQL')
import { sql } from '@nitric/sdk'
// opts param with dialect property
const db = sql('my-database', { dialect: 'MySQL' })
import { sql } from '@nitric/sdk'
// new methods for creating specific db types
const db = sql.postgres('my-database')

Curious what others think.