|
20 | 20 | import org.jetbrains.annotations.Nullable; |
21 | 21 | import org.labkey.api.data.Container; |
22 | 22 | import org.labkey.api.data.ContainerManager; |
| 23 | +import org.labkey.api.data.DbSchema; |
| 24 | +import org.labkey.api.data.SqlExecutor; |
| 25 | +import org.labkey.api.data.TableInfo; |
23 | 26 | import org.labkey.api.data.TableSelector; |
24 | 27 | import org.labkey.api.files.FileContentService; |
25 | 28 | import org.labkey.api.files.TableUpdaterFileListener; |
| 29 | +import org.labkey.api.module.DatabaseMigration; |
| 30 | +import org.labkey.api.module.DatabaseMigration.DefaultMigrationHandler; |
26 | 31 | import org.labkey.api.module.DefaultModule; |
27 | 32 | import org.labkey.api.module.ModuleContext; |
28 | 33 | import org.labkey.api.pipeline.PipelineService; |
@@ -125,6 +130,26 @@ public void doStartup(ModuleContext moduleContext) |
125 | 130 | } |
126 | 131 |
|
127 | 132 | ProteinService.get().registerProteinSearchView(new ProteinSearchViewProvider()); |
| 133 | + DatabaseMigration.registerHandler(ProteinSchema.getSchema(), new DefaultMigrationHandler() |
| 134 | + { |
| 135 | + @Override |
| 136 | + public void beforeSchema(DbSchema targetSchema) |
| 137 | + { |
| 138 | + new SqlExecutor(targetSchema).execute("ALTER TABLE prot.Organisms DROP CONSTRAINT FK_ProtOrganisms_ProtIdentifiers"); |
| 139 | + } |
| 140 | + |
| 141 | + @Override |
| 142 | + public List<TableInfo> getTablesToCopy(DbSchema targetSchema) |
| 143 | + { |
| 144 | + return super.getTablesToCopy(targetSchema); |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public void afterSchema(DbSchema targetSchema) |
| 149 | + { |
| 150 | + new SqlExecutor(targetSchema).execute("ALTER TABLE prot.Organisms ADD CONSTRAINT FK_ProtOrganisms_ProtIdentifiers FOREIGN KEY (IdentId) REFERENCES prot.Identifiers (IdentId)"); |
| 151 | + } |
| 152 | + }); |
128 | 153 | } |
129 | 154 |
|
130 | 155 | @Override |
|
0 commit comments