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

herbs update - Entities with relationship #145

Open
dalssoft opened this issue Jul 5, 2022 · 1 comment
Open

herbs update - Entities with relationship #145

dalssoft opened this issue Jul 5, 2022 · 1 comment
Labels
enhancement New feature or request hacktoberfest

Comments

@dalssoft
Copy link
Member

dalssoft commented Jul 5, 2022

Would be great if we improve the behavior of herbs update for cases when entities have relationship with other entities.

one-to-one

    entity('ToDoList', {
        id: field(Number),
        items: field(Item),

This should create a migration with:

            return knex.schema
                .createTable('ToDoList', function (table) {
                    table.string('id').primary()
                    table.string('itemId').references('id').inTable('Item')
                })

one-to-many

    entity('ToDoList', {
        id: field(Number),
        items: field([Item]),

This should create a migration with:

            return knex.schema
                .createTable('ToDoList', function (table) {
                    table.string('id').primary()
                    ...
                })

                .alterTable('Item', function (table) {
                    table.string('itemId').references('id').inTable('ToDoList')
                    ...
                })
@dalssoft
Copy link
Member Author

dalssoft commented Jul 5, 2022

@endersoncosta is working on it PR: #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest
Projects
Status: Ready to code
Development

No branches or pull requests

2 participants