 --
 
 CREATE TABLE favorite_authors (
-    id        serial  PRIMARY KEY,
-    user_id   integer NOT NULL REFERENCES users,
-    author_id integer NOT NULL REFERENCES authors
+    id        serial PRIMARY KEY,
+    user_id   int    NOT NULL REFERENCES users,
+    author_id int    NOT NULL REFERENCES authors
 );
 
 CREATE TABLE favorite_series (
-    id        serial  PRIMARY KEY,
-    user_id   integer NOT NULL REFERENCES users,
-    series_id integer NOT NULL REFERENCES book_series
+    id        serial PRIMARY KEY,
+    user_id   int    NOT NULL REFERENCES users,
+    series_id int    NOT NULL REFERENCES book_series
 );
 
 CREATE TABLE favorite_translators (
-    id            serial  PRIMARY KEY,
-    user_id       integer NOT NULL REFERENCES users,
-    translator_id integer NOT NULL REFERENCES translation_groups
+    id            serial PRIMARY KEY,
+    user_id       int    NOT NULL REFERENCES users,
+    translator_id int    NOT NULL REFERENCES translation_groups
 );
 
 CREATE TABLE favorite_magazines (
-    id          serial  PRIMARY KEY,
-    user_id     integer NOT NULL REFERENCES users,
-    magazine_id integer NOT NULL REFERENCES magazines
+    id          serial PRIMARY KEY,
+    user_id     int    NOT NULL REFERENCES users,
+    magazine_id int    NOT NULL REFERENCES magazines
 );
 
 CREATE TABLE favorite_book_tags (
-    id      serial  PRIMARY KEY,
-    user_id integer NOT NULL REFERENCES users,
-    tag_id  integer NOT NULL REFERENCES book_tag_names
+    id      serial PRIMARY KEY,
+    user_id int    NOT NULL REFERENCES users,
+    tag_id  int    NOT NULL REFERENCES book_tag_names
 );
 
 CREATE TABLE favorite_character_tags (
-    id      serial  PRIMARY KEY,
-    user_id integer NOT NULL REFERENCES users,
-    tag_id  integer NOT NULL REFERENCES character_tag_names
+    id      serial PRIMARY KEY,
+    user_id int    NOT NULL REFERENCES users,
+    tag_id  int    NOT NULL REFERENCES character_tag_names
 );
 
 --

    aliases     text[],
    nationality text,
    birthday    date, -- the year is ignored
    sex         integer,
    weight      real,
    height      real,
    sizes       text,
    blood_type  integer,
    description text,
    picture     boolean NOT NULL DEFAULT false
);

CREATE TABLE characters_roles (
    id           serial  PRIMARY KEY,
    character_id integer NOT NULL REFERENCES characters,
    series_id    integer NOT NULL REFERENCES book_series,
    type         integer NOT NULL,
    role         integer,
    appearances  integer[] --           REFERENCES chapters
);

CREATE VIEW series_characters AS

CREATE EXTENSION intarray;

-- schema version (increment whenever it changes)
CREATE TABLE schema_version ( revision int NOT NULL );
INSERT INTO schema_version VALUES (0);

--
