diff --git a/migrations/2019-08-15-123406_identifiers/down.sql b/migrations/2019-08-15-123406_identifiers/down.sql new file mode 100644 index 0000000..9069a7e --- /dev/null +++ b/migrations/2019-08-15-123406_identifiers/down.sql @@ -0,0 +1,2 @@ +ALTER TABLE languages DROP COLUMN identifier; +ALTER TABLE wrappers DROP COLUMN identifier; diff --git a/migrations/2019-08-15-123406_identifiers/up.sql b/migrations/2019-08-15-123406_identifiers/up.sql new file mode 100644 index 0000000..9091290 --- /dev/null +++ b/migrations/2019-08-15-123406_identifiers/up.sql @@ -0,0 +1,44 @@ +ALTER TABLE languages ADD COLUMN identifier text; + +UPDATE languages SET identifier = CASE name + WHEN 'Plain text' THEN 'plain-text' + WHEN 'C' THEN 'c' + WHEN 'C++' THEN 'c-plus-plus' + WHEN 'C#' THEN 'c-sharp' + WHEN 'Haskell' THEN 'haskell' + WHEN 'HTML' THEN 'html' + WHEN 'Java' THEN 'java' + WHEN 'JavaScript' THEN 'javascript' + WHEN 'Jinja2' THEN 'jinja2' + WHEN 'JSX' THEN 'jsx' + WHEN 'Markdown' THEN 'markdown' + WHEN 'Perl' THEN 'perl' + WHEN 'Perl 6' THEN 'perl6' + WHEN 'PHP' THEN 'php' + WHEN 'PostgreSQL' THEN 'postgresql' + WHEN 'Python 2' THEN 'python2' + WHEN 'Python 3' THEN 'python3' + WHEN 'Rust' THEN 'rust' + WHEN 'Sh' THEN 'sh' + WHEN 'SQL' THEN 'sql' + WHEN 'SQLite' THEN 'sqlite' + WHEN 'TypeScript' THEN 'typescript' + WHEN 'TypeScript-JSX' THEN 'typescript-jsx' + END; + +CREATE INDEX ON languages (identifier); + +ALTER TABLE languages ALTER COLUMN identifier SET NOT NULL; + +ALTER TABLE wrappers ADD COLUMN identifier text; + +UPDATE wrappers SET identifier = CASE label + WHEN 'Run' THEN 'run' + WHEN 'Format (black)' THEN 'format' + WHEN 'Rustfmt' THEN 'format' + WHEN 'ASM' THEN 'asm' + END; + +ALTER TABLE wrappers ALTER COLUMN identifier SET NOT NULL; + +CREATE INDEX ON wrappers (identifier); diff --git a/src/schema.rs b/src/schema.rs index 57f535c..e15fd58 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -6,6 +6,7 @@ table! { highlighter_mode -> Nullable, mime -> Text, is_markdown -> Bool, + identifier -> Text, } } @@ -29,6 +30,7 @@ table! { ordering -> Int4, is_formatter -> Bool, is_asm -> Bool, + identifier -> Text, } }