Fix word name collision, add two new user-related features
All checks were successful
continuous-integration/drone/push Build is passing

This commit changes the primary key of words to a serial number. That
way, two words with the same normalized value will not collide with
one another.

It also adds two new tables in the database:
- Users following languages
- Users learning words

The former can represent two stages of learning a word:
- Either the user is currently learning it
- Or they consider they know it and don’t need to work on it anymore

These two new tables now have their API query available through the
GraphQL API.

This commit also fixes the issue of word-related tables and types not
being dropped when resetting the database.
This commit is contained in:
2023-01-18 10:26:45 +01:00
parent b5dfdee453
commit c5f5e770e2
10 changed files with 227 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
-- This file should undo anything in `up.sql`
DROP TABLE UserFollowLanguage;
DROP TABLE LangAndAgents;
DROP TABLE LangTranslatesTo;
DROP TABLE Languages;

View File

@@ -51,3 +51,17 @@ CREATE TABLE LangAndAgents (
NOT NULL,
relationship AgentLanguageRelation NOT NULL
);
CREATE TABLE UserFollowLanguage (
id SERIAL PRIMARY KEY,
lang UUID
REFERENCES Languages(id)
ON UPDATE CASCADE
ON DELETE CASCADE
NOT NULL,
userid VARCHAR(31)
REFERENCES Users(id)
ON UPDATE CASCADE
ON DELETE CASCADE
NOT NULL
);