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

Add Schema Load Lifecycle RFC #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

diogotcorreia
Copy link

@diogotcorreia diogotcorreia commented Jun 16, 2020

Addresses issue strapi/strapi#5972

As requested, here goes my RFC about the schema load lifecycle.

Preview Link: https://github.com/diogotcorreia/rfcs/blob/0005-schema-load-lifecycles/rfcs/0005-schema-load-lifecycles.md

@alexandrebodin
Copy link
Member

Hi @diogotcorreia can you add a link to the preview of the RFC in the description plz :)

@diogotcorreia
Copy link
Author

Done :)

@alexandrebodin
Copy link
Member

Thank you for this RFC @diogotcorreia. I will review it in details. Just to give you more info, we are planning on refactor the DB layer a lot before the end of year and we will certainly support some sort of schema lifecycles to do any customization. If we were to implement something now be aware we will probably break it for Strapi v4 :)

@alexandrebodin
Copy link
Member

Thanks for this RFC.

Here are somme comments:

  • I think we should put the schema specific lifecycles outside of the lifecycles key like in idea 2

  • Here are some lifecycles I think we could have:

    • before the schema is created to change some schema options
    • after the schema is created to use it (generating indexes for ex)
    • some way to update the process of database table creation (future versions)
  • I think we should be passing some ctx to those lifecycles:

    • connection info (client info)
    • orm instance
    • model info

@derrickmehaffy
Copy link
Member

some way to update the process of database table creation (future versions)

@alexandrebodin can you expand on this suggestion?

@diogotcorreia
Copy link
Author

@alexandrebodin
Updated RFC in response to your comments

@alexandrebodin
Copy link
Member

Thanks for the improvements !

I think the lifecycles arguments should be passed as an object so we can make it evolve without breaking changes and have potentially different infos per connectors.

Other stuff I would like to see (to answer @derrickmehaffy)

There are a lot of possible events. I need to review our process but here is what comes to my mind:

  • before / after schema creation (attributes / fileds config, relation)
  • before / after model creation (new Schema or new Model in the ORM)
  • before / after dbmodel creation
  • before / after dbmodel deletion
  • before / after dbmodel edition

Once we define the exact events we can define the APIs for each of them

@alexandrebodin alexandrebodin changed the title Add Schema Load Lifecycle RFC (0005) Add Schema Load Lifecycle RFC Sep 15, 2020
@strapi-cla
Copy link

strapi-cla commented Jan 21, 2021

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

4 participants