Skip to content

Issue with constraint when applying to existing data #232

@OmarHawk

Description

@OmarHawk

Hi,

I just tried the Blueprint on an existing database where there are already plenty of lines inside the database tables. The Blueprint adds for each of the Audit Fields NOT NULL constraints. This does not work for existing tables with data as adding the constraint will cause such an error during startup while applying the generated liquibase changesets as there is no column default on the two user columns, therefore the newly created columns contain solely NULL values.

 Data truncation: Invalid use of NULL value [Failed SQL: (1138) ALTER TABLE fx.my_data MODIFY created_by VARCHAR(50) NOT NULL]

Maybe, we could introduce a default value (system (?) - just like the fallback during runtime) for the created_by / last_modified_by columns which can immediately be dropped after initial creation of the columns, just as with the two date columns...
Alternatively, at least state this behaviour regarding Constraints clearer in the README, by maybe adjusting this sentence:

This will also add new columns to the entities, so it is ideal to recreate the tables if you are enabling this for existing entities or use incremental changelog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions