word: reorder table columns
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 2 Jul 2021 16:03:55 +0000 (18:03 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 5 Jul 2021 01:54:37 +0000 (03:54 +0200)
tools/word.pg.sql

index 7aacfa88d5cfb8f76fba04699e9ea87df8adc692..fb1e5d11a586d388a5641a7d2edf091eb1091192 100644 (file)
@@ -20,8 +20,8 @@ CREATE TABLE word (
        source     text                 CHECK (source ~ '^https?://'),
        thumb      text[],
        wptitle    text,
-       created    timestamptz          DEFAULT now(),
        creator    integer              REFERENCES login (id),
+       created    timestamptz          DEFAULT now(),
        updated    timestamptz,
        id         serial      NOT NULL PRIMARY KEY
 );
@@ -54,14 +54,13 @@ CREATE OR REPLACE VIEW _word_ref AS
                coalesce(r.cat,     w.cat    ) cat, --TODO translate w?
                coalesce(r.ref,     r.id     ) "ref",
                coalesce(r.prio,    w.prio   ) prio,
+               coalesce(r.grade,   w.grade  ) grade,
+               coalesce(r.cover,   w.cover  ) cover,
                coalesce(r.source,  w.source ) source,
                coalesce(r.thumb,   w.thumb  ) thumb,
                coalesce(r.wptitle, w.wptitle) wptitle,
-               r.created, r.updated,
-               CASE WHEN r.source IS NULL THEN w.id ELSE r.id END id, -- image id
-               coalesce(r.cover,   w.cover  ) cover,
-               coalesce(r.grade,   w.grade  ) grade,
-               r.creator
+               r.creator, r.created, r.updated,
+               CASE WHEN r.source IS NULL THEN w.id ELSE r.id END id -- image id
        FROM word r
        LEFT JOIN word w ON w.id = r.ref;