Skip to content
cccskills
FreePublished on GitHub

flyway-migration

Expert knowledge of Flyway database migrations in melosys-api (Oracle DB). Use when: (1) Creating new database migrations, (2) Understanding migration versioning and naming, (3) Debugging migration failures, (4) Understanding Oracle-specific SQL patterns, (5) Adding tables, columns, or indexes. Triggers: "create migration", "new Flyway migration", "add column/table/index", "Flyway error", "checksum mismatch", "ORA-00955", "ORA-02292", "ORA-01430", "migration failed", "validate failed".

The English summary is being prepared. Showing the original description.

See how to install

Files included (2)

  • SKILL.md5.5 KB
  • references/debugging.md5.4 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Flyway Migration Skill

Expert knowledge of Flyway database migrations for melosys-api's Oracle database.

Quick Reference

Migration Location

app/src/main/resources/db/migration/melosysDB/

Versioning Convention

PatternExampleUse Case
V{N}__V150__name.sqlMajor feature (current scheme)
V{N}.{M}__V4.4_01__name.sqlGrouped related changes (legacy)
V{N}.{M}_{NN}__V5.1_12__name.sqlSub-feature in group (legacy)

Rules:

  • Use double underscore __ after version
  • Use descriptive snake_case names
  • Never modify existing migrations
  • Find latest version: ls -la app/src/main/resources/db/migration/melosysDB/ | tail -5

Current Version Range

Versions span from V1.0_01 (legacy dotted scheme) up through the current flat V15x series. Newer migrations use plain integer versions (V150__, V151__, ...). Always check the existing files for the true latest version before creating a new one — do not assume a fixed top number, it drifts:

ls app/src/main/resources/db/migration/melosysDB/ | sort -V | tail -5

Common Patterns

Create Table

CREATE TABLE my_table (
    id              NUMBER(19) GENERATED ALWAYS AS IDENTITY,
    fagsak_id       VARCHAR2(99) NOT NULL,
    status          VARCHAR2(50) NOT NULL,
    registrert_dato TIMESTAMP NOT NULL,
    endret_dato     TIMESTAMP NOT NULL,
    CONSTRAINT pk_my_table PRIMARY KEY (id),
    CONSTRAINT fk_my_table_fagsak FOREIGN KEY (fagsak_id) REFERENCES fagsak
);

CREATE INDEX idx_my_table_fagsak ON my_table(fagsak_id);

Create Lookup Table (Kodeverk)

CREATE TABLE my_type (
    kode VARCHAR2(50) NOT NULL,
    navn VARCHAR2(100) NOT NULL,
    CONSTRAINT pk_my_type PRIMARY KEY (kode)
);

INSERT INTO my_type(kode, navn) VALUES ('VALUE1', 'Description 1');
INSERT INTO my_type(kode, navn) VALUES ('VALUE2', 'Description 2');

Add Column

ALTER TABLE behandling ADD (
    my_column VARCHAR2(100) NULL
);

Add Column with Default

ALTER TABLE behandling ADD (
    my_flag NUMBER(1) DEFAULT 0 NOT NULL
);

Add Foreign Key

ALTER TABLE my_table ADD CONSTRAINT fk_my_table_ref
    FOREIGN KEY (ref_id) REFERENCES other_table;

Add Index

CREATE INDEX idx_my_table_column ON my_table(column_name);
CREATE UNIQUE INDEX idx_my_table_unique ON my_table(column1, column2);

Insert Process Type/Step

INSERT INTO PROSESS_TYPE(KODE, NAVN)
VALUES ('MY_PROCESS', 'Description of process');

INSERT INTO PROSESS_STEG(kode, navn)
VALUES ('MY_STEP', 'Description of step');

JSON Column (CLOB with constraint)

CREATE TABLE my_json_table (
    id   NUMBER(19) GENERATED ALWAYS AS IDENTITY,
    data CLOB NOT NULL,
    CONSTRAINT pk_my_json PRIMARY KEY (id),
    CONSTRAINT json_my_data CHECK (data IS JSON) ENABLE
);

Oracle-Specific Syntax

Data Types

TypeUsage
NUMBER(19)IDs, large integers
NUMBER(1)Boolean flags
VARCHAR2(N)Variable text
CLOBLarge text/JSON
TIMESTAMPDate/time
DATEDate only

Identity Columns

-- Auto-increment ID
id NUMBER(19) GENERATED ALWAYS AS IDENTITY

Sequences

CREATE SEQUENCE my_seq
MINVALUE 1
NOMAXVALUE
INCREMENT BY 1;

Configuration

Maven Plugin (app/pom.xml)

<plugin>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-maven-plugin</artifactId>
    <version>${flyway.version}</version>
</plugin>

Profile Settings

ProfileFlyway Enabled
local-mockYes (default)
local-q1No
local-q2No
naisYes

Commands

Check Migration Status

# Via Makefile
make db-info

# Via Maven
mvn flyway:info -pl app

Run Migrations

# Via Makefile
make db-migrate

# Via Maven
mvn flyway:migrate -pl app

Application Startup

Flyway runs automatically on application startup (unless disabled).

Debugging Migration Failures

For migration failures — checksum mismatch, ORA-00955 (object already exists), ORA-02292 (child record found), ORA-01430 (column already exists), partially applied migrations, flyway:repair/baseline, and local rollback — see references/debugging.md. It also covers flyway_schema_history inspection queries and safe column add/remove/rename patterns.

Best Practices

  1. One logical change per migration
  2. Test locally first with USE_LOCAL_DB=true
  3. Never modify existing migrations in production
  4. Use descriptive names that explain the change
  5. Include indexes for foreign keys and query columns
  6. Use NOT NULL where possible for data integrity
  7. Add constraints with meaningful names (pk_, fk_, idx_, chk_)

Related Skills

  • database: Schema structure and tables
  • kodeverk: Lookup tables and enums
  • behandling: Treatment tables
  • fagsak: Case tables

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Expert knowledge of Altinn A1 application processing for posted workers in melosys-api. Use when: (1) Understanding Altinn søknad/skjema processing, (2) Debugging MedlemskapArbeidEOS form mapping, (3) Understanding SoeknadMapper transformations, (4) Investigating posted worker application issues, (5) Understanding the MOTTAK_SOKNAD_ALTINN saga flow.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Expert knowledge of Employer/Employment integration (EREG/AAREG) in melosys-api. Use when: (1) Working with organization data from EREG (Enhetsregisteret), (2) Working with employment data from AAREG (Arbeidsforhold), (3) Understanding employer/organization lookup, (4) Debugging employer or employment issues, (5) Understanding the mapping between register data and domain models. Triggers: orgnummer, arbeidsforhold, EREG, AAREG, Enhetsregisteret, registeropplysninger, ansettelsesperiode, saksopplysning.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Modular monolith architecture overview for melosys-api. Use when needing to understand module structure, dependencies between modules, where to place new code, or when changes in one module might affect others. Triggers: "architecture", "module dependencies", "where should I put", "which modules", "dependency graph".

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Expert knowledge of Behandling (case treatment) domain in melosys-api. Use when: (1) Understanding the behandling lifecycle and status transitions, (2) Debugging issues with behandling creation, status changes, or closure, (3) Understanding relationships between Fagsak, Behandling, and Behandlingsresultat, (4) Investigating why a behandling is stuck or has wrong status, (5) Understanding Behandlingstyper, Behandlingstema, Behandlingsstatus enums, (6) Debugging journalføring or SED-triggered behandling creation, (7) Understanding behandling creation via saksflyt sagas.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

Expert knowledge of Behandlingsresultat (treatment result) domain in melosys-api. Use when: (1) Understanding result types and their meaning (FASTSATT_LOVVALGSLAND, MEDLEM_I_FOLKETRYGDEN, etc.), (2) Working with periods - Lovvalgsperiode, Medlemskapsperiode, Anmodningsperiode, Utpekingsperiode, (3) Debugging vedtak/decision metadata, criteria evaluation, or social insurance charges, (4) Understanding EU/EEA coordination logic and Article 16 exception handling, (5) Working with trygdeavgift (social insurance charge) calculations.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

brev

Free

Expert knowledge of Brev (letter generation) in melosys-api. Use when: (1) Producing letters and decision documents (vedtaksbrev), (2) Understanding Dokgen templates and mapping, (3) Configuring letter recipients and distribution, (4) Debugging letter generation issues, (5) Adding new letter types or templates.

The English summary is being prepared. Showing the original description.

navikt/melosys-api2Updated Oct 21, 2026

See all skills by navikt

Report a problem with this skill