Add languages, user_names, users_public tables and routes; fix _se→_sv rename
- Fix broken rename migration array (sed had corrupted from values to _sv) - Add languages table with status lifecycle and trilingual titles - Add user_names table with unique lowercase index - Add users_public table linking to user_names and languages (native/target) - Wire all three new routes under /api/languages, /api/user-names, /api/users-public Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,17 +56,17 @@ router.get('/:id', async (req, res, next) => {
|
||||
router.post('/', async (req, res, next) => {
|
||||
try {
|
||||
const {
|
||||
negative_sentence_de, negative_sentence_en, negative_sentence_se,
|
||||
positive_sentence_de, positive_sentence_en, positive_sentence_se,
|
||||
negative_sentence_de, negative_sentence_en, negative_sentence_sv,
|
||||
positive_sentence_de, positive_sentence_en, positive_sentence_sv,
|
||||
blocked_topic,
|
||||
} = req.body;
|
||||
const result = await query(
|
||||
`INSERT INTO statements
|
||||
(negative_sentence_de, negative_sentence_en, negative_sentence_se,
|
||||
positive_sentence_de, positive_sentence_en, positive_sentence_se, blocked_topic)
|
||||
(negative_sentence_de, negative_sentence_en, negative_sentence_sv,
|
||||
positive_sentence_de, positive_sentence_en, positive_sentence_sv, blocked_topic)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7) RETURNING *`,
|
||||
[negative_sentence_de || null, negative_sentence_en || null, negative_sentence_se || null,
|
||||
positive_sentence_de || null, positive_sentence_en || null, positive_sentence_se || null,
|
||||
[negative_sentence_de || null, negative_sentence_en || null, negative_sentence_sv || null,
|
||||
positive_sentence_de || null, positive_sentence_en || null, positive_sentence_sv || null,
|
||||
blocked_topic || null]
|
||||
);
|
||||
res.status(201).json({ ...result.rows[0], positive_word_ids: [], negative_word_ids: [] });
|
||||
@@ -77,8 +77,8 @@ router.post('/', async (req, res, next) => {
|
||||
router.patch('/:id', async (req, res, next) => {
|
||||
try {
|
||||
const allowed = ['status', 'blocked_topic', 'published_at', 'blocked_at',
|
||||
'negative_sentence_de', 'negative_sentence_en', 'negative_sentence_se',
|
||||
'positive_sentence_de', 'positive_sentence_en', 'positive_sentence_se'];
|
||||
'negative_sentence_de', 'negative_sentence_en', 'negative_sentence_sv',
|
||||
'positive_sentence_de', 'positive_sentence_en', 'positive_sentence_sv'];
|
||||
const fields = Object.keys(req.body).filter(k => allowed.includes(k));
|
||||
if (!fields.length) return res.status(400).json({ error: 'No valid fields provided' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user