Edgewall Software

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 drop_tables method to DatabaseManager class. Added method to ConnectionBase class for dropping a column: drop_column.

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:1 by Ryan J Ollos, 9 years ago

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.

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Ryan J Ollos, 9 years ago

Summary: DatabaseManager should support adding a column to a tableDatabaseManager should support adding and removing table columns

comment:3 by Ryan J Ollos, 9 years ago

Milestone: next-dev-1.1.xnext-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 Ryan J Ollos, 8 years ago

Milestone: next-dev-1.3.x1.2
Owner: set to Ryan J Ollos
Status: newassigned

comment:5 by Ryan J Ollos, 8 years ago

API Changes: modified (diff)

This is being addressed as part of #9612.

comment:6 by Jun Omae, 8 years ago

+1. dropping column would be faster than drop/create table for #9612.

comment:7 by Christian Boos, 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.

comment:8 by Ryan J Ollos, 8 years ago

API Changes: modified (diff)

Added in [6ce60c5d/rjollos.git].

Notes:

TravisCI tests are passing.

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

in reply to:  8 comment:9 by Jun Omae, 8 years ago

Replying to Ryan J Ollos:

Unit tests pass with PostgreSQL 8.4.20 on CentOS 6.

comment:10 by Ryan J Ollos, 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 Ryan J Ollos, 8 years ago

API Changes: modified (diff)
Note: See TracTickets for help on using tickets.