Opened 9 years ago
Last modified 8 years ago
#11872 closed enhancement
DatabaseManager should support adding and removing table columns — at Version 11
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2 |
Component: | database backend | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: |
Added |
||
Internal Changes: |
Description
The DatabaseManager
class has methods to create and drop tables (#11512). It would be useful to have a method to add a column to a table.
Change History (11)
comment:2 by , 9 years ago
Summary: | DatabaseManager should support adding a column to a table → DatabaseManager should support adding and removing table columns |
---|
comment:3 by , 9 years ago
Milestone: | next-dev-1.1.x → next-dev-1.3.x |
---|
Narrowing focus for milestone:1.2. Please move ticket to milestone:1.2 if you intend to fix it.
comment:4 by , 8 years ago
Milestone: | next-dev-1.3.x → 1.2 |
---|---|
Owner: | set to |
Status: | new → assigned |
comment:7 by , 8 years ago
SQLite seems to support ADD COLUMN, but still not DROP COLUMN. The other backends could of course do it as an optimization.
follow-up: 9 comment:8 by , 8 years ago
API Changes: | modified (diff) |
---|
Added in [6ce60c5d/rjollos.git].
Notes:
- MySQL doesn't support
IF EXISTS
- PostgreSQL < 9.0 doesn't support
IF EXISTS
, however ≥ 9.0 does - I didn't test with PostgreSQL 8.x. I think we should consider dropping PostgreSQL < 9.0 soon: TracDev/ApiChanges/1.3.
TravisCI tests are passing.
comment:9 by , 8 years ago
Replying to Ryan J Ollos:
- PostgreSQL < 9.0 doesn't support
IF EXISTS
, however ≥ 9.0 does
Unit tests pass with PostgreSQL 8.4.20 on CentOS 6.
comment:10 by , 8 years ago
I noticed a mix of self.cnx.cursor
and self.cursor()
used in the methods. Is there a good way to know which should be used?: trunk/trac/db/sqlite_backend.py@14911:365,401#L364
comment:11 by , 8 years ago
API Changes: | modified (diff) |
---|
A
drop_column
method could be useful as well. One use-case in #9612.The approach to adding columns has been to create a temporary table for the data and drop/re-create the table. For example: tags/trac-1.0.2/trac/upgrades/db11.py.