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

feature: add rename to DeltaItem trait and support rename for column/constraints of the table #4

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

tyrchen
Copy link
Owner

@tyrchen tyrchen commented Jan 10, 2023

Previously rename is not addressed. Due to the natural of the diffing, it will be treated as drop/create for the column/constraints if the only change is just name.

A new logic is added for specific case: if only one column/constraint is removed and one new column/constraint is added, we will check if this is a rename case.

// check if it is a case for rename
if self.added.len() == 1 && self.removed.len() == 1 {
    let added = self.added.iter().next().unwrap();
    let removed = self.removed.iter().next().unwrap();
    let result = removed.to_owned().rename(item, added.to_owned())?;
    if !result.is_empty() {
        migrations.extend(result);
        is_rename = true;
    }
}

@tyrchen
Copy link
Owner Author

tyrchen commented Jan 10, 2023

Fixed #3

@tyrchen tyrchen merged commit b3efdb8 into master Jan 10, 2023
@tyrchen tyrchen deleted the feature/support-column-and-constraint-rename branch January 10, 2023 08:03
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.

1 participant