Skip to content

Instantly share code, notes, and snippets.

@ayroblu
Created June 20, 2017 05:55
Show Gist options
  • Save ayroblu/ce56b703c2d213822c68d437d17d3bbc to your computer and use it in GitHub Desktop.
Save ayroblu/ce56b703c2d213822c68d437d17d3bbc to your computer and use it in GitHub Desktop.
Declarative DB
--Init:
CREATE TABLE table_name(
id INT PRIMARY KEY
, name TEXT NOT NULL
)
--Later on:
CREATE TABLE table_name(
id INT PRIMARY KEY
, name TEXT NOT NULL
, age TEXT NOT NULL
)
--This leads to a migration like:
--up
ALTER TABLE table_name ADD COLUMN age TEXT NOT NULL
--down
ALTER TABLE table_name DROP COLUMN age
-- Couldn't we have something like react which would compare the two table declarations
-- and create the necessary alter table statement if required?
-- For simplicity purposes, this could even be a yaml declaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment