mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
add system dependency checks (php-curl, sqlite3) to deploy-server.sh step 0
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
-- Migration 019: Add "Écriture" format type
|
||||
INSERT INTO format_types (name) VALUES ('Écriture');
|
||||
INSERT OR IGNORE INTO format_types (name) VALUES ('Écriture');
|
||||
|
||||
31
app/migrations/pending/033_dedup_format_types.sql
Normal file
31
app/migrations/pending/033_dedup_format_types.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
-- 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;
|
||||
Reference in New Issue
Block a user