Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

I need to add unique column to an existing propel entity

U04BCHQVACE Posts: 39 🧑🏻‍🚀 - Cadet
edited June 2023 in Help

I need to add a new column to an existing propel entity. That column needs to be unique. The problem I have is that it will fail when adding the unique index, due to the unique constraints for the existing records will be checked (all the new columns have a default empty string value).

How can I add a specific migration or sql to be run to make sure I populate those rows with derived unique values before I attempt to create the unique index?



  • jochen.gartner
    jochen.gartner Posts: 42 🧑🏻‍🚀 - Cadet

    Well if you generate migrations locally and commit them to be run on other environments, you can of course adjust the auto-generated sql to match your needs (in your case add the column without the constraint, update records with your unique value, create the constraint). I'm not aware of any other way to do this.

    U04BCHQVACE Posts: 39 🧑🏻‍🚀 - Cadet

    Thanks Jochen. Is there any docs on how to create migrations with propel?