mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
fix: add upload-progress.js to partage form (progress bar was missing on public submissions)
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
-- Migration 033: Deduplicate format_types rows (caused by repeated runs of migration 019).
|
||||
-- For each name, keep the row with the lowest id, reassign thesis_formats references.
|
||||
|
||||
-- 1. Map each duplicate format_id → canonical format_id
|
||||
CREATE TEMP TABLE _fmt_map AS
|
||||
SELECT
|
||||
dup.id AS old_id,
|
||||
(
|
||||
SELECT MIN(keep.id)
|
||||
FROM format_types keep
|
||||
WHERE keep.name = dup.name
|
||||
) AS new_id
|
||||
FROM format_types dup
|
||||
WHERE dup.id != (
|
||||
SELECT MIN(keep.id)
|
||||
FROM format_types keep
|
||||
WHERE keep.name = dup.name
|
||||
);
|
||||
|
||||
-- 2. Update affected thesis_formats rows
|
||||
UPDATE thesis_formats
|
||||
SET format_id = (
|
||||
SELECT new_id FROM _fmt_map WHERE old_id = format_id
|
||||
)
|
||||
WHERE format_id IN (SELECT old_id FROM _fmt_map);
|
||||
|
||||
-- 3. Delete duplicate rows
|
||||
DELETE FROM format_types
|
||||
WHERE id IN (SELECT old_id FROM _fmt_map);
|
||||
|
||||
DROP TABLE _fmt_map;
|
||||
52
app/migrations/pending/034_dedup_all_lookup_tables.sql
Normal file
52
app/migrations/pending/034_dedup_all_lookup_tables.sql
Normal file
@@ -0,0 +1,52 @@
|
||||
-- Migration 034: Deduplicate all lookup tables that have no UNIQUE on name/key/slug.
|
||||
-- Root cause: INSERT OR IGNORE is ineffective without a UNIQUE constraint,
|
||||
-- and schema.sql was applied repeatedly during broken-migration-runner era.
|
||||
|
||||
-- ── access_types ──
|
||||
DELETE FROM access_types WHERE id NOT IN (SELECT MIN(id) FROM access_types GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_access_types_name_unique ON access_types(name);
|
||||
|
||||
-- ── ap_programs ──
|
||||
DELETE FROM ap_programs WHERE id NOT IN (SELECT MIN(id) FROM ap_programs GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_ap_programs_name_unique ON ap_programs(name);
|
||||
|
||||
-- ── finality_types ──
|
||||
DELETE FROM finality_types WHERE id NOT IN (SELECT MIN(id) FROM finality_types GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_finality_types_name_unique ON finality_types(name);
|
||||
|
||||
-- ── languages ──
|
||||
DELETE FROM languages WHERE id NOT IN (SELECT MIN(id) FROM languages GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_languages_name_unique ON languages(name);
|
||||
|
||||
-- ── license_types ──
|
||||
DELETE FROM license_types WHERE id NOT IN (SELECT MIN(id) FROM license_types GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_license_types_name_unique ON license_types(name);
|
||||
|
||||
-- ── orientations ──
|
||||
DELETE FROM orientations WHERE id NOT IN (SELECT MIN(id) FROM orientations GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_orientations_name_unique ON orientations(name);
|
||||
|
||||
-- ── pages ──
|
||||
DELETE FROM pages WHERE id NOT IN (SELECT MIN(id) FROM pages GROUP BY slug);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_pages_slug_unique ON pages(slug);
|
||||
|
||||
-- ── apropos_contents ──
|
||||
DELETE FROM apropos_contents WHERE id NOT IN (SELECT MIN(id) FROM apropos_contents GROUP BY key);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_apropos_contents_key_unique ON apropos_contents(key);
|
||||
|
||||
-- ── tags ──
|
||||
DELETE FROM tags WHERE id NOT IN (SELECT MIN(id) FROM tags GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_tags_name_unique ON tags(name);
|
||||
|
||||
-- ── supervisors ──
|
||||
DELETE FROM supervisors WHERE id NOT IN (SELECT MIN(id) FROM supervisors GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_supervisors_name_unique ON supervisors(name);
|
||||
|
||||
-- ── format_types ── (re-run in case any crept back)
|
||||
DELETE FROM format_types WHERE id NOT IN (SELECT MIN(id) FROM format_types GROUP BY name);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_format_types_name_unique ON format_types(name);
|
||||
|
||||
-- ── Clean up authors with empty email (soft-deleted or dummy rows)
|
||||
-- These come from CSV import artefacts. Keep only the first per email.
|
||||
DELETE FROM authors WHERE id NOT IN (SELECT MIN(id) FROM authors GROUP BY email);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_authors_email_unique ON authors(email);
|
||||
Reference in New Issue
Block a user