01: /*
02: * Created by IntelliJ IDEA.
03: * User: sg426575
04: * Date: Apr 27, 2006
05: * Time: 3:12:28 AM
06: */
07: package com.technoetic.xplanner.upgrade;
08:
09: import com.tacitknowledge.util.migration.MigrationException;
10:
11: /**
12: * Make sure we cannot delete files that are still referenced by notes
13: * If constaints on the note table has a different name, access mysql manually though mysql client: mysql -u xplanner -p xplanner
14: * Run 'show create table note'
15: * Change from patch0007_iteration45_47.sql:
16: * Removed following statement from patch0007_iteration45_47.sql:
17: * alter table note add constraint noteAttachment foreign key (attachment_id) references xfile (id);
18: * table person
19: * Foreign Key FK68AF8F596607D1C Reference id <- story.customer_id
20: * Foreign Key FK0015856662D8A5 Reference id <- story.customer_id
21: * Foreign Key FK90D2EE1032DA9A45 Reference id <- notification_receivers.person_id
22: *
23: */
24: public class CleanUpNoteTableConstraints extends
25: JdbcMigrationTaskSupport {
26:
27: public CleanUpNoteTableConstraints() {
28: super ("cleanup_note_constraints", 13);
29: }
30:
31: public void migrate() throws MigrationException {
32: migrater.withNoException().dropForeignKeyConstraint("note",
33: "FK33AFF2A62F61B7");
34: migrater.withNoException().dropForeignKeyConstraint("note",
35: "false");
36: migrater.withNoException().dropForeignKeyConstraint("note",
37: "noteAttachment");
38: migrater.withNoException().dropForeignKeyConstraint("note",
39: "noteAttachments");
40:
41: migrater.addForeignKeyConstraint("note", "noteAttachments",
42: "attachment_id", "xfile", "id");
43: }
44:
45: public static void main(String[] args) throws Exception {
46: new CleanUpAttachments().run();
47: }
48:
49: }
|