use sequence per tenant

This commit is contained in:
gowthaman 2024-05-23 13:40:28 +05:30
parent 0c9313b77c
commit d51c8c7547
2 changed files with 5 additions and 15 deletions

View File

@ -7,8 +7,7 @@ Authorization: {{auth-token}}
"data": {
"number": "KA01HD6677",
"owner": "gowthaman"
},
"uniqueIdentifier": "KA01HD6677"
}
}
### create row
@ -55,17 +54,6 @@ Authorization: Bearer {{auth-token}}
GET http://localhost:9001/api/vehicle/KA01HD6677
Authorization: Bearer {{auth-token}}
### query row
POST http://localhost:9001/api/vehicle/query
Content-Type: application/json
Authorization: {{set-auth-token}}
{
"sql": "select sys_pk, tenant_id, deleted_on, deleted_by, deleted, version, created_at, modified_at, created_by, modified_by, data, tags, comments, unique_identifier, entity_name from data_model where data ->> 'number' = :number",
"params": {
"number": "KA03HD6064"
}
}
### search row
POST http://localhost:9001/api/vehicle/search
@ -73,7 +61,8 @@ Content-Type: application/json
Authorization: {{auth-token}}
{
"number": "KA01HD6677"
"number": "KA01HD6677",
"owner": "gowthaman"
}
### update field

View File

@ -206,7 +206,8 @@ object Session {
.findOne() ?: throw DataNotFoundException
}
private fun seqName(entity: String) = "sequence_$entity"
private fun seqName(entity: String) = "sequence_${entity}_${currentTenant()}"
fun creatSeq(entity: String): Int {
return database.sqlUpdate("CREATE SEQUENCE IF NOT EXISTS ${seqName(entity)} START 1;").execute()
}