Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

Liquibase: managing master data

$
0
0

I am using liquibase in my project.

I have tenant table with tenant_id as primary key. And the remaining tables have tenant_id as a column.

Now what will be the better way to handle master data with different tenants

Tables:

<createTable tableName="tenant"> <column name="tenant_id" autoIncrement="true" type="int"> <constraints primaryKey="true" nullable="false" primaryKeyName="pk_tenant_id" /> </column> <column name="name" type="varchar(100)"></column> </createTable> <createTable tableName="base_entity"> <column name="base_entity_id" autoIncrement="true" type="int"> <constraints primaryKey="true" nullable="false" primaryKeyName="pk_base_entity_id" /> </column> <column name="tenant_id" type="int"> <constraints nullable="false" /> </column> </createTable> 

-- Data: -- Currently I am handling data like this

 <property name="@tenant_id_1" value="(select tenant_id from tenant where name='test1') " dbms="mysql" /> <property name="@tenant_id_2" value="(select tenant_id from tenant where name='test2') " dbms="mysql" /> <insert tableName="tenant"> <column name="name">test1</column> </insert> <insert tableName="tenant"> <column name="name">test2</column> </insert> <insert tableName="base_entity"> <column name="name">testBase_Entity</column> <column name="tenant_id" valueComputed="${@tenant_id_1}" /> </insert> <insert tableName="base_entity"> <column name="name">testBase_Entity</column> <column name="tenant_id" valueComputed="${@tenant_id_2}" /> </insert> 

But I have 'n' no of tenants, for every entry of tenant I've to insert the data.

Is there any option in liquibase do this in a better way ?

Thanks in advance.


Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>