Skip to content

add_column() should support REFERENCES {other_table}({other_column}) #16

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

Closed
simonw opened this issue Feb 24, 2019 · 4 comments
Closed

Comments

@simonw
Copy link
Owner

simonw commented Feb 24, 2019

Related to #2

@simonw simonw modified the milestone: 1.0 May 25, 2019
@simonw
Copy link
Owner Author

simonw commented May 29, 2019

For the CLI I'm thinking:

sqlite-utils add-column data.db mytable col text --fk othertable id

So the foreign key is added using --fk othertable othercolumn

If the user doesn't provide the column type we can derive it from the foreign key.

Can we make the othercolumn optional? That would be neat - then we could automatically detect it using the sole primary key of the referenced table.

@simonw
Copy link
Owner Author

simonw commented May 29, 2019

Hmm... probably not:

For options, only a fixed number of arguments is supported.

@simonw
Copy link
Owner Author

simonw commented May 29, 2019

In that case --fk othertable detects the primary key.

If you want to point at a different column, use --fk-col X

@simonw simonw closed this as completed in 50e2f94 May 29, 2019
@simonw
Copy link
Owner Author

simonw commented May 29, 2019

Shipped this feature in sqlite-utils 1.1: https://sqlite-utils.readthedocs.io/en/latest/changelog.html#v1-1

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

No branches or pull requests

1 participant