-
Notifications
You must be signed in to change notification settings - Fork 0
Dev #32
Dev #32
Changes from all commits
438762b
f9a37fc
05ade02
7dcef56
ce9afd8
43d1e0c
f29c553
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,8 @@ | |
| @NoArgsConstructor | ||
| public class MediaModel implements Serializable { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen_medias") | ||
| @SequenceGenerator(name = "gen_medias", sequenceName = "seq_medias", allocationSize = 50) | ||
|
Comment on lines
+42
to
+43
|
||
| @Column(name = "id_media") | ||
| private Integer id; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,8 @@ | |
| @NoArgsConstructor | ||
| public class PeopleModel implements Serializable { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen_people") | ||
| @SequenceGenerator(name = "gen_people", sequenceName = "seq_people", allocationSize = 50)) | ||
|
Comment on lines
+30
to
+31
|
||
| @Column(name = "id_person") | ||
| private Integer id; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| CREATE SEQUENCE seq_medias START WITH 1 INCREMENT BY 50; | ||||||||||||||||||||||||||||||||||||||||||||
| CREATE SEQUENCE seq_externals_references START WITH 1 INCREMENT BY 50; | ||||||||||||||||||||||||||||||||||||||||||||
| CREATE SEQUENCE seq_alternative_titles START WITH 1 INCREMENT BY 50; | ||||||||||||||||||||||||||||||||||||||||||||
| CREATE SEQUENCE seq_people START WITH 1 INCREMENT BY 50; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| ALTER SEQUENCE seq_medias RESTART WITH 458830; | ||||||||||||||||||||||||||||||||||||||||||||
| ALTER SEQUENCE seq_externals_references RESTART WITH 201324; | ||||||||||||||||||||||||||||||||||||||||||||
| ALTER SEQUENCE seq_alternative_titles RESTART WITH 122752; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
| ALTER SEQUENCE seq_alternative_titles RESTART WITH 122752; | |
| ALTER SEQUENCE seq_alternative_titles RESTART WITH 122752; | |
| ALTER SEQUENCE seq_people RESTART WITH 1000000; |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ALTER SEQUENCE ... RESTART WITH <hard-coded> values make this migration environment/data dependent. If IDs differ between environments (or future restores), this can either cause collisions or waste large ID ranges. Prefer computing MAX(id)+1 at migration time (e.g., via dynamic SQL) to make the migration deterministic.
| ALTER SEQUENCE seq_medias RESTART WITH 458830; | |
| ALTER SEQUENCE seq_externals_references RESTART WITH 201324; | |
| ALTER SEQUENCE seq_alternative_titles RESTART WITH 122752; | |
| DO $$ | |
| DECLARE | |
| v_next_value bigint; | |
| BEGIN | |
| -- Set seq_medias based on current data | |
| SELECT COALESCE(MAX(id), 0) + 1 INTO v_next_value FROM medias; | |
| PERFORM setval('seq_medias', v_next_value, false); | |
| -- Set seq_externals_references based on current data | |
| SELECT COALESCE(MAX(id), 0) + 1 INTO v_next_value FROM externals_references; | |
| PERFORM setval('seq_externals_references', v_next_value, false); | |
| -- Set seq_alternative_titles based on current data | |
| SELECT COALESCE(MAX(id), 0) + 1 INTO v_next_value FROM alternative_titles; | |
| PERFORM setval('seq_alternative_titles', v_next_value, false); | |
| END; | |
| $$; |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this migration, idx_title is dropped from medias, but the previous migration creates idx_title on alternative_titles (see V15). Dropping it from the wrong table will fail at runtime; drop idx_title from alternative_titles instead (and keep idx_name drop on medias if intended).
| ALTER TABLE medias DROP INDEX idx_title; | |
| ALTER TABLE alternative_titles DROP INDEX idx_title; |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migration drops idx_name/idx_title, but the corresponding JPA entities still declare these indexes via @Table(indexes=...) (MediaModel has idx_name, AlternativeTitleModel has idx_title). With spring.jpa.hibernate.ddl-auto=update, Hibernate may recreate the indexes on startup, effectively undoing this migration. If the goal is to permanently remove these indexes, also remove/adjust the @Index annotations (or set ddl-auto to validate).
| ALTER SEQUENCE seq_alternative_titles RESTART WITH 122752; | |
| ALTER TABLE medias DROP INDEX idx_title; | |
| ALTER TABLE medias DROP INDEX idx_name; | |
| ALTER SEQUENCE seq_alternative_titles RESTART WITH 122752; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AlternativeTitleModelnow uses@SequenceGeneratorbut this file doesn't importjakarta.persistence.SequenceGenerator, so it won't compile. Add the missing import (or consolidate JPA imports).