Skip to content

Commit 9f2c176

Browse files
Merge pull request #108 from pierrick-fonquerne/106-scripts-de-migration-ajouter-lauto-enregistrement-dans-migration_history
fix(database): add self-registration to migration scripts (#106)
2 parents 95e3e23 + 6fc66e3 commit 9f2c176

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

database/sql/001_create_tables.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,8 @@ CREATE TABLE comments (
103103
CREATE INDEX idx_comments_character_id ON comments(character_id);
104104
CREATE INDEX idx_comments_author_id ON comments(author_id);
105105
CREATE INDEX idx_comments_pending ON comments(character_id) WHERE status = 'pending';
106+
107+
-- Record migration
108+
INSERT INTO migration_history (filename, checksum, execution_time_ms, applied_by)
109+
VALUES ('001_create_tables.sql', 'v1', 0, 'manual')
110+
ON CONFLICT (filename) DO NOTHING;

database/sql/002_add_user_audit_columns.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ CREATE TRIGGER trigger_users_updated_at
2020
BEFORE UPDATE ON users
2121
FOR EACH ROW
2222
EXECUTE FUNCTION update_updated_at_column();
23+
24+
-- Record migration
25+
INSERT INTO migration_history (filename, checksum, execution_time_ms, applied_by)
26+
VALUES ('002_add_user_audit_columns.sql', 'v1', 0, 'manual')
27+
ON CONFLICT (filename) DO NOTHING;

database/sql/003_create_reference_tables.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ INSERT INTO equipment_slots (name, display_order) VALUES
4242
('Anneau 2', 12),
4343
('Main droite', 13),
4444
('Main gauche', 14);
45+
46+
-- Record migration
47+
INSERT INTO migration_history (filename, checksum, execution_time_ms, applied_by)
48+
VALUES ('003_create_reference_tables.sql', 'v1', 0, 'manual')
49+
ON CONFLICT (filename) DO NOTHING;

database/sql/004_evolve_characters_table.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ CREATE INDEX idx_characters_gallery ON characters(is_shared, status)
3131

3232
-- Index for filtering by status (moderation views)
3333
CREATE INDEX idx_characters_status ON characters(status);
34+
35+
-- Record migration
36+
INSERT INTO migration_history (filename, checksum, execution_time_ms, applied_by)
37+
VALUES ('004_evolve_characters_table.sql', 'v1', 0, 'manual')
38+
ON CONFLICT (filename) DO NOTHING;

0 commit comments

Comments
 (0)