Project

General

Profile

how to add a column to a relational table created from a many to many relation

Added by samira hosseini about 5 years ago

Hi all,

I need to add a column to a relational table which is created from a many to many relation. this type of table is not created by writing related codes and does not have any corresponding class in the codes.


Replies (2)

RE: how to add a column to a relational table created from a many to many relation - Added by lm at about 5 years ago

I'm not exactly sure what you're wanting, but the easiest way to "add" a column to a table is to drop the entire database (delete the database file in the case of sqlite), then re-create it.

In fact, I think that's the only way Wt::Dbo can do it. If you want to keep the data, you'll need to write your own update statement. You perhaps can have Wt::Dbo run this update statement for you, but that sounds like more trouble than it's worth: I would just run the update statement "by hand" outside Wt::Dbo.

RE: how to add a column to a relational table created from a many to many relation - Added by Wim Dumon about 5 years ago

I'm also not sure how to interpret the original question. Dbo has indeed no mechanism to update databases, and I'm not sure if I trust in general such operations to an automated system - a lot of data can go lost when the wrong migration has been chosen. We write migration scripts by hand and check them in in the project, executing them when the software is upgraded.

Wim.

    (1-2/2)