0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-25 09:09:35 +01:00
svelte/site/migrations/001-create-gists.js
Luke Edwards 1d0da9d022 Use database for REPL, update URL structure (#2572)
* fix: move `shelljs` to dev-deps

* fix: move `codemirror` to “external” config only

* fix: move `yootils` to “external” config only

* chore: bump “sirv” dep

* chore: regenerate pkg-lock

* chore: add `.env.example` file

* chore: remove previous dependencies

* chore: add users migration

* feat: add `db` util w/ pool

* feat: handle GitHub OAuth directly, thru JWTs

* fix: hydrate `user` data & update keys

* fix: add timestamp columns to “users" table

* feat: save new gists to database

* feat: find & update gists

* fix: update client for new endpoints

* fix: always send { error } shape

* fix: rename “users.token” => "users.github_token”

* chore: include node-fetch as dev-dep

* fix: remove extra DATABASE_URL key

* fix: upload OAuth popup message

* chore: regenerate lock file

* add database entries for new gists, update REPL URLs

* implement saving and forking

* insert history entry when forking

* add logic for relaxed gists

* remove unnecessary on conflict clause
2019-05-05 00:33:30 -04:00

25 lines
675 B
JavaScript

exports.up = DB => {
DB.sql(`
create table if not exists gists (
id serial primary key,
uid uuid NOT NULL DEFAULT gen_random_uuid(),
user_id integer REFERENCES users(id) not null,
name character varying(255) not null,
files json not null,
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone
);
create unique index if not exists gists_pkey ON gists(id int4_ops);
create index if not exists gists_user_id_key ON gists(user_id int4_ops);
`);
};
exports.down = DB => {
DB.sql(`
drop table if exists gists cascade;
drop index if exists gists_user_id_key;
drop index if exists gists_pkey;
`);
};