Skip to content

Commit c48cdc2

Browse files
committed
Register handlers for schema-specific functionality
1 parent 7505542 commit c48cdc2

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

protein/src/org/labkey/protein/ProteinModule.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020
import org.jetbrains.annotations.Nullable;
2121
import org.labkey.api.data.Container;
2222
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;
2326
import org.labkey.api.data.TableSelector;
2427
import org.labkey.api.files.FileContentService;
2528
import org.labkey.api.files.TableUpdaterFileListener;
29+
import org.labkey.api.module.DatabaseMigration;
30+
import org.labkey.api.module.DatabaseMigration.DefaultMigrationHandler;
2631
import org.labkey.api.module.DefaultModule;
2732
import org.labkey.api.module.ModuleContext;
2833
import org.labkey.api.pipeline.PipelineService;
@@ -125,6 +130,26 @@ public void doStartup(ModuleContext moduleContext)
125130
}
126131

127132
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+
});
128153
}
129154

130155
@Override

0 commit comments

Comments
 (0)