Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with constraint when applying to existing data #232

Open
OmarHawk opened this issue Mar 1, 2024 · 2 comments
Open

Issue with constraint when applying to existing data #232

OmarHawk opened this issue Mar 1, 2024 · 2 comments

Comments

@OmarHawk
Copy link
Contributor

OmarHawk commented Mar 1, 2024

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.

@OmarHawk
Copy link
Contributor Author

Releates to jhipster/generator-jhipster#25094 - I'd like to introduce some defaults, using the merge request I'm preparing there.

@OmarHawk
Copy link
Contributor Author

usign the defaultValue option, we could introduce the system user as the default column value for the two user columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant