Skip to content

herbs update - Entities with relationship #145

Description

@dalssoft

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')
                    ...
                })

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions