migrations and normalizing
migrations and normalizing
- Subject: migrations and normalizing
- From: Theodore Petrosky <email@hidden>
- Date: Fri, 3 Dec 2010 18:21:52 -0800 (PST)
I am using migrations to normalize my postgresql backend. I needed to factor out some columns into a new table. the only way I thought of was to use the COPY command to a file then read the file back into my new table.
/*
* copies the data out to the file then
* copies it back to the new table
*/
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
"COPY (select id, c_invoice_number, c_invoice_date, c_invoice_booked_date, 't', " +
"'f' from t_version where c_is_invoiced) " +
"TO '/Users/asacksadmin/Desktop/selectedInvoices.txt'");
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
"COPY t_invoice (c_version_id, c_invoice_number, c_invoice_date, c_invoice_booked_date, " +
"c_is_final_invoice, c_is_partial_invoice) " +
"FROM '/Users/asacksadmin/Desktop/selectedInvoices.txt'");
/*
* drops the columns from the version table that are
* no longer used
*
* c_invoice_booked_date
* c_invoice_number
* c_invoice_date
*
*/
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
"ALTER TABLE t_version drop COLUMN c_invoice_booked_date");
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
"ALTER TABLE t_version drop COLUMN c_invoice_number");
ERXJDBCUtilities.executeUpdate(database.adaptorChannel(),
"ALTER TABLE t_version drop COLUMN c_invoice_date");
so i got it to work and I am thinking, "Is there a better way?" Of course this leaves behind the file selectedInvoices.txt on the desktop but that is the only artifact left over.
Maybe it's not so bad after all. but I thought I would ask. "Is there a better way?"
Ted
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden