yiisoft / yiisoft/db-migration
SQLite does not support addForeignKey()
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 32
- Forks
- 18
- Avg merge
- 22h 18m
- Merged PRs (30d)
- 2
Description
SQLite does not support addForeignKey() but supports foreign key constraints inside columns definitions of CREATE TABLE query.
https://www.sqlite.org/foreignkeys.html
CREATE TABLE track(
trackid INTEGER,
trackname TEXT,
trackartist INTEGER,
FOREIGN KEY(trackartist) REFERENCES artist(artistid)
);
The follow command throws an Exception in SQLite
./yii migrate:create post --command=table --fields='department_id:integer:notNull:foreignKey(department)'
Due to column foreign key is initialized separately
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the yii migrate:create command against SQLite, then inspect resources/views/_createTable.php at the linked lines and compare its generated SQL with SQLite's foreign-key syntax. Done means the command no longer throws an exception and the generated CREATE TABLE query includes the requested foreign-key constraint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100