This page demonstrate how to add or edit a column/table and developing the necessary objects for facilitate the change. The page use a example to demonstrate how create new column date_edited in the table core.client and show how to wire everything up.
opensrp
directory migrate new "client table add date_edited" --path=assets/migration
opensrp/assets/migrations/scripts
. In my case it created the file 20180416141726_client_table_add_date_edited.sql. The first part is timestamp and rest depending on the arguments passed -- // client table add date_edited
--
Migration SQL that makes the change goes here.
Write the DDL to undo the change in the section below
-- //@UNDO
-- SQL to undo the change goes here.
Save the sql file. The sql file should look like the below
-- // client table add date_edited -- Migration SQL that makes the change goes here. ALTER TABLE core.client ADD COLUMN date_edited timestamp DEFAULT CURRENT_TIMESTAMP; -- //@UNDO -- SQL to undo the change goes here. ALTER TABLE core.client DROP COLUMN date_edited; |
migrate up --path=assets/migrations --env=test
migrate down --path=assets/migrations --env=test
opensrp/assets/migrations/generator/generatorConfig.xml
make sure the table that you changed is active(uncommented)opensrp/assets/migrations/generator/generatorConfig.xml
and select Run As >> Run MyBatis Generatororg.opensrp.repository.postgres.mapper.custom
and mappers xml are in the package org.opensrp.repository.postgres.mapper.custom.xml