Ticket #52 (closed defect: fixed)
Implement SQLite alter/rename/drop column via workarounds
| Reported by: | andrew | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | The Future |
| Component: | databaseapi | Version: | 0.4 |
| Keywords: | Cc: |
Description
Currently these just raise exceptions in the SQLite commands, but it would be nice to have these "just work", using workarounds like http://grass.osgeo.org/wiki/Sqlite_Drop_Column
Attachments
Change History
comment:4 Changed 4 years ago by andrew
- Milestone changed from 0.4 to The Future
Looks like this will require manually parsing the content of sqlite_master, which is not a feature I'm willing to roll in to 0.4 at this point. Pushing to The Future.
At this rate, 0.5 will be the parsing-a-plenty release.
comment:5 Changed 4 years ago by Robert <trebor74hr@…>
What is suggested on page http://grass.osgeo.org/wiki/Sqlite_Drop_Column
is very similar what is already done and obviously works in django-evolution. Place is db.sqlite3.EvolutionOperations?.delete_column i.e.
http://code.google.com/p/django-evolution/source/browse/trunk/django_evolution/db/sqlite3.py#9.
Basically:
- dump data to new temp table without the column
- drop table
- create table without the column
- copy data from temp table
- drop temp table
Why not reuse the logic/code and enable this. Btw. this type of scenario is base for all kind of implementations where db engine doesn't support SQL DDL command (alter table, alter column, rename column, drop column, add column, etc.). Later most of unsupported operations for various engines could be implemented in the same manner.
comment:6 Changed 4 years ago by andrew
- Version set to 0.4
The major problem with implementing this so far has, in fact, been in determining the schema of the new temp table - previously, it would have involved parsing of the only data SQLite gives you about tables (their CREATE TABLE statement).
Now, someone's working on doing it using the ORM. Updates to follow.
Changed 4 years ago by angri
- Attachment svn-260-alter-sqlite.patch added
patch which can do the trick
comment:7 Changed 4 years ago by angri
It was not tested with every column type supported by django. But I think it is a good start and it may be usefull for somebody.
--
Anton Gritsay
anton@…
comment:9 Changed 4 years ago by andrew
It's being worked on in a separate fork; rename_column was merged in a while ago, others weren't ready.
comment:10 Changed 4 years ago by Velmont
So it'll get in the next release?
comment:11 Changed 4 years ago by andrew
Hopefully. Can't say much more just yet.
comment:12 Changed 4 years ago by olau@…
Hi, just hit this page via Google. Actually I just did this by hand - instead of creating a tmp table, you can just rename the old table to tmp and use that as source.
comment:13 Changed 3 years ago by andrew
- Status changed from assigned to closed
- Resolution set to fixed
0.7 fixes this.
