-
Notifications
You must be signed in to change notification settings - Fork 13
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
Make schema file idempotent #63
Make schema file idempotent #63
Conversation
I'm not quite sure if the backend should apply the schema without checking. If it is idempotent and you'll do this in production, you skipped the migrations. |
It is just about the dev setup for now, for production we'll have to see how we apply the schema in the future. In the dev setup, this approach is in line with how the datastore currently builds the datastore: In the entrypoint, the schema is simply tried to be applied, regardless of whether or not that's necessary. In OpenSlides/openslides-backend#2315 in the backend, I would like to do the same in the backend: Apply the schema in the entrypoint to make sure that the new schema exists. This is only possible if the schema is idempotent. The make target is of no help, since that would destroy the current database, which contains the old schema. |
We should discuss the advantages and disadvantages of this PR. Please do not merge! |
I'm not quite sure if the backend should apply the schema without checking. If it is idempotent and you'll do this in production, you skipped the migrations.
IMO there exist no use case, where you want to deploy a modified schema to an existing database. This is only useful with a migration, otherwise you may have a corrupt database. If you want to apply a new schema without migration, you have to delete the old data in database. In comparison to the non relational schema, here we always change the physical schema. |
I still think that it does no harm and provides benefits for development purposes to make the schema idempotent. If we do not want this, however, we should at least be consistent within the schema - either all commands should be idempotent or none. |
No need for discussion anymore. The relational schema was made to fail if you try to apply it a second time. This could only lead to a corrupt database changing the schema without migrating data. |
@r-peschke with these changes, the schema can be applied multiple times without errors. This is important for the backend so that the entrypoint can simply try to setup the schema without doing any checks first.