tighten the api
This commit is contained in:
parent
31388bae59
commit
f35851d339
2
.gitignore
vendored
2
.gitignore
vendored
@ -41,3 +41,5 @@ bin/
|
|||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
application.yaml
|
application.yaml
|
||||||
|
initial-data.sql
|
||||||
|
*.env.json
|
||||||
13
api.http
13
api.http
@ -1,19 +1,19 @@
|
|||||||
### create row
|
### create row
|
||||||
POST http://localhost:9001/api/vehicle
|
POST http://localhost:9001/api/vehicle
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: set-auth-token
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"number": "TN36BA5009"
|
"number": "KA01MU0556"
|
||||||
},
|
},
|
||||||
"uniqueIdentifier": "TN36BA5009"
|
"uniqueIdentifier": "KA01MU0556"
|
||||||
}
|
}
|
||||||
|
|
||||||
### create row, with autogenerated identifier
|
### create row, with autogenerated identifier
|
||||||
POST http://localhost:9001/api/log
|
POST http://localhost:9001/api/log
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: set-auth-token
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
@ -23,7 +23,8 @@ Authorization: set-auth-token
|
|||||||
}
|
}
|
||||||
|
|
||||||
### get row
|
### get row
|
||||||
GET http://localhost:9001/api/vehicle/KA03HD6064
|
GET http://localhost:9001/api/vehicle/TN36BA5009
|
||||||
|
Authorization: Bearer {{auth-token}}
|
||||||
|
|
||||||
### query row
|
### query row
|
||||||
POST http://localhost:9001/api/vehicle/query
|
POST http://localhost:9001/api/vehicle/query
|
||||||
@ -40,7 +41,7 @@ Authorization: set-auth-token
|
|||||||
### update field
|
### update field
|
||||||
PATCH http://localhost:9001/api/vehicle/KA03HD6064
|
PATCH http://localhost:9001/api/vehicle/KA03HD6064
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: set-auth-token
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"key": "ownerName",
|
"key": "ownerName",
|
||||||
|
|||||||
@ -5,8 +5,10 @@ app.db.user=postgres
|
|||||||
app.db.pass=postgres
|
app.db.pass=postgres
|
||||||
app.db.url=jdbc:postgresql://192.168.64.6/modules_app
|
app.db.url=jdbc:postgresql://192.168.64.6/modules_app
|
||||||
app.db.run_migration=true
|
app.db.run_migration=true
|
||||||
|
app.db.seed_sql=initial-data.sql
|
||||||
app.iam.url=https://auth.compegence.com
|
app.iam.url=https://auth.compegence.com
|
||||||
app.iam.realm=forewarn-dev
|
app.iam.realm=forewarn-dev
|
||||||
app.iam.client=forewarn
|
app.iam.client=forewarn
|
||||||
app.iam.client_redirect_uri=http://localhost:9001/auth/code
|
app.iam.client_redirect_uri=http://localhost:9001/auth/code
|
||||||
app.cache.redis_uri=redis://127.0.0.1:6379/0
|
app.cache.redis_uri=redis://127.0.0.1:6379/0
|
||||||
|
app.scripts.path=/tmp
|
||||||
@ -25,9 +25,9 @@ dependencies {
|
|||||||
implementation("io.ebean:ebean-ddl-generator:13.23.2")
|
implementation("io.ebean:ebean-ddl-generator:13.23.2")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.+")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.15.+")
|
||||||
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.+")
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.15.+")
|
||||||
|
implementation("ch.qos.logback:logback-core:1.4.11")
|
||||||
|
implementation("ch.qos.logback:logback-classic:1.4.11")
|
||||||
implementation("org.bitbucket.b_c:jose4j:0.9.3")
|
implementation("org.bitbucket.b_c:jose4j:0.9.3")
|
||||||
implementation("org.slf4j:slf4j-simple:2.0.7")
|
|
||||||
implementation("redis.clients:jedis:5.0.2")
|
implementation("redis.clients:jedis:5.0.2")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-scripting-jsr223:1.9.0")
|
implementation("org.jetbrains.kotlin:kotlin-scripting-jsr223:1.9.0")
|
||||||
api ("net.cactusthorn.config:config-core:0.81")
|
api ("net.cactusthorn.config:config-core:0.81")
|
||||||
|
|||||||
@ -26,7 +26,6 @@ class AppAccessManager : AccessManager {
|
|||||||
|
|
||||||
override fun manage(handler: Handler, ctx: Context, routeRoles: Set<RouteRole>) {
|
override fun manage(handler: Handler, ctx: Context, routeRoles: Set<RouteRole>) {
|
||||||
val pathParamMap = ctx.pathParamMap()
|
val pathParamMap = ctx.pathParamMap()
|
||||||
logger.warn("access {}, {}", pathParamMap, routeRoles)
|
|
||||||
val regex = Regex("^[a-zA-Z0-9\\-_\\.]+$")
|
val regex = Regex("^[a-zA-Z0-9\\-_\\.]+$")
|
||||||
|
|
||||||
if (pathParamMap.values.count { !regex.matches(it) } > 0) {
|
if (pathParamMap.values.count { !regex.matches(it) } > 0) {
|
||||||
@ -35,15 +34,16 @@ class AppAccessManager : AccessManager {
|
|||||||
val entity = pathParamMap["entity"]
|
val entity = pathParamMap["entity"]
|
||||||
val action = pathParamMap["action"]
|
val action = pathParamMap["action"]
|
||||||
|
|
||||||
val allowedRoles = routeRoles.map { it as Role }.flatMap {
|
val allowedRoles = routeRoles.map { it as Roles }.flatMap { it.roles.toList() }.flatMap { role ->
|
||||||
when (it) {
|
when (role) {
|
||||||
Role.DbOps -> listOf("ROLE_DB_OPS")
|
Role.DbOps -> listOf("ROLE_DB_OPS")
|
||||||
Role.Entity -> loadEntityActionRole(entity, action)
|
Role.Entity -> loadEntityActionRole(entity, action)
|
||||||
is Role.Standard -> listOf("ROLE_${entity}_${it.action}")
|
is Role.Standard -> role.action.toList().map { "ROLE_${entity}_${it}" }
|
||||||
}.map(String::uppercase)
|
}.map(String::uppercase)
|
||||||
}
|
}
|
||||||
|
|
||||||
val isAllowed = currentRoles().count { allowedRoles.contains(it) } > 0
|
val isAllowed = currentRoles().count { allowedRoles.contains(it) } > 0
|
||||||
|
logger.warn("entity - $entity, action $action, userroles = ${currentRoles()}, allowed = $allowedRoles, isAllowed? $isAllowed, enforce? ${appConfig.enforceRoleRestriction()}")
|
||||||
if (isAllowed || !appConfig.enforceRoleRestriction() || allowedRoles.isEmpty()) {
|
if (isAllowed || !appConfig.enforceRoleRestriction() || allowedRoles.isEmpty()) {
|
||||||
//if role is allowed, or enforcement is turned off or no roles are explicitly allowed
|
//if role is allowed, or enforcement is turned off or no roles are explicitly allowed
|
||||||
handler.handle(ctx)
|
handler.handle(ctx)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import com.restapi.domain.DataNotFoundException
|
|||||||
import com.restapi.domain.Session.objectMapper
|
import com.restapi.domain.Session.objectMapper
|
||||||
import com.restapi.domain.Session.redis
|
import com.restapi.domain.Session.redis
|
||||||
import com.restapi.domain.Session.setAuthorizedUser
|
import com.restapi.domain.Session.setAuthorizedUser
|
||||||
|
import io.ebean.DataIntegrityException
|
||||||
import io.ebean.DuplicateKeyException
|
import io.ebean.DuplicateKeyException
|
||||||
import io.javalin.Javalin
|
import io.javalin.Javalin
|
||||||
import io.javalin.apibuilder.ApiBuilder.*
|
import io.javalin.apibuilder.ApiBuilder.*
|
||||||
@ -19,6 +20,7 @@ import io.javalin.http.util.NaiveRateLimit
|
|||||||
import io.javalin.http.util.RateLimitUtil
|
import io.javalin.http.util.RateLimitUtil
|
||||||
import io.javalin.json.JavalinJackson
|
import io.javalin.json.JavalinJackson
|
||||||
import io.javalin.security.RouteRole
|
import io.javalin.security.RouteRole
|
||||||
|
import org.jose4j.jwt.consumer.InvalidJwtException
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
@ -108,8 +110,6 @@ fun main(args: Array<String>) {
|
|||||||
?.replace("Bearer: ", "")
|
?.replace("Bearer: ", "")
|
||||||
?.trim() ?: throw UnauthorizedResponse()
|
?.trim() ?: throw UnauthorizedResponse()
|
||||||
|
|
||||||
logger.warn("authToken = $authToken")
|
|
||||||
|
|
||||||
setAuthorizedUser(parseAuthToken(authToken = authToken))
|
setAuthorizedUser(parseAuthToken(authToken = authToken))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,34 +139,54 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
.exception(DuplicateKeyException::class.java) { _, ctx ->
|
.exception(DuplicateKeyException::class.java) { e, ctx ->
|
||||||
|
logger.warn("while processing ${ctx.path()}, exception ${e.message}", e)
|
||||||
ctx.json(
|
ctx.json(
|
||||||
mapOf(
|
mapOf(
|
||||||
"error" to "Duplicate Data"
|
"error" to "Duplicate Data"
|
||||||
)
|
)
|
||||||
).status(HttpStatus.CONFLICT)
|
).status(HttpStatus.CONFLICT)
|
||||||
}
|
}
|
||||||
.exception(DataNotFoundException::class.java) { _, ctx ->
|
.exception(DataIntegrityException::class.java) { e, ctx ->
|
||||||
|
logger.warn("while processing ${ctx.path()}, exception ${e.message}", e)
|
||||||
|
ctx.json(
|
||||||
|
mapOf(
|
||||||
|
"error" to "References Missing"
|
||||||
|
)
|
||||||
|
).status(HttpStatus.EXPECTATION_FAILED)
|
||||||
|
}
|
||||||
|
.exception(DataNotFoundException::class.java) { e, ctx ->
|
||||||
|
logger.warn("while processing ${ctx.path()}, exception ${e.message}", e)
|
||||||
ctx.json(
|
ctx.json(
|
||||||
mapOf(
|
mapOf(
|
||||||
"error" to "Data Not Found"
|
"error" to "Data Not Found"
|
||||||
)
|
)
|
||||||
).status(HttpStatus.NOT_FOUND)
|
).status(HttpStatus.NOT_FOUND)
|
||||||
}
|
}
|
||||||
.exception(IllegalArgumentException::class.java) { _, ctx ->
|
.exception(IllegalArgumentException::class.java) { e, ctx ->
|
||||||
|
logger.warn("while processing ${ctx.path()}, exception ${e.message}", e)
|
||||||
ctx.json(
|
ctx.json(
|
||||||
mapOf(
|
mapOf(
|
||||||
"error" to "Incorrect Data"
|
"error" to "Incorrect Data"
|
||||||
)
|
)
|
||||||
).status(HttpStatus.BAD_REQUEST)
|
).status(HttpStatus.BAD_REQUEST)
|
||||||
}
|
}
|
||||||
.exception(JsonMappingException::class.java) { _, ctx ->
|
.exception(JsonMappingException::class.java) { e, ctx ->
|
||||||
|
logger.warn("while processing ${ctx.path()}, exception ${e.message}", e)
|
||||||
ctx.json(
|
ctx.json(
|
||||||
mapOf(
|
mapOf(
|
||||||
"error" to "Incorrect Data"
|
"error" to "Incorrect Data"
|
||||||
)
|
)
|
||||||
).status(HttpStatus.BAD_REQUEST)
|
).status(HttpStatus.BAD_REQUEST)
|
||||||
}
|
}
|
||||||
|
.exception(InvalidJwtException::class.java) { e, ctx ->
|
||||||
|
logger.warn("while processing ${ctx.path()}, exception ${e.message}", e)
|
||||||
|
ctx.json(
|
||||||
|
mapOf(
|
||||||
|
"error" to "Login required"
|
||||||
|
)
|
||||||
|
).status(HttpStatus.UNAUTHORIZED)
|
||||||
|
}
|
||||||
.start(appConfig.portNumber())
|
.start(appConfig.portNumber())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,9 @@ interface AppConfig {
|
|||||||
@Key("app.db.run_migration")
|
@Key("app.db.run_migration")
|
||||||
fun dbRunMigration(): Boolean
|
fun dbRunMigration(): Boolean
|
||||||
|
|
||||||
|
@Key("app.db.seed_sql")
|
||||||
|
fun seedSqlFile(): Optional<String>
|
||||||
|
|
||||||
@Key("app.iam.url")
|
@Key("app.iam.url")
|
||||||
fun iamUrl(): String
|
fun iamUrl(): String
|
||||||
|
|
||||||
|
|||||||
@ -140,6 +140,7 @@ object Entities {
|
|||||||
if (this.uniqueIdentifier.isEmpty()) {
|
if (this.uniqueIdentifier.isEmpty()) {
|
||||||
this.uniqueIdentifier = Session.nextUniqId(entity)
|
this.uniqueIdentifier = Session.nextUniqId(entity)
|
||||||
}
|
}
|
||||||
|
this.approvalStatus = ApprovalStatus.APPROVED
|
||||||
}
|
}
|
||||||
|
|
||||||
database.save(
|
database.save(
|
||||||
|
|||||||
@ -32,6 +32,9 @@ object Session {
|
|||||||
setProperty("datasource.db.password", appConfig.dbPass())
|
setProperty("datasource.db.password", appConfig.dbPass())
|
||||||
setProperty("datasource.db.url", appConfig.dbUrl())
|
setProperty("datasource.db.url", appConfig.dbUrl())
|
||||||
setProperty("ebean.migration.run", appConfig.dbRunMigration().toString())
|
setProperty("ebean.migration.run", appConfig.dbRunMigration().toString())
|
||||||
|
if(appConfig.seedSqlFile().isPresent){
|
||||||
|
setProperty("ebean.ddl.seedSql", appConfig.seedSqlFile().get())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
tenantMode = TenantMode.PARTITION
|
tenantMode = TenantMode.PARTITION
|
||||||
currentTenantProvider = CurrentTenantProvider { currentUser.get().tenant }
|
currentTenantProvider = CurrentTenantProvider { currentUser.get().tenant }
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer
|
|||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||||
import io.ebean.Model
|
import io.ebean.Model
|
||||||
import io.ebean.annotation.DbArray
|
import io.ebean.annotation.DbArray
|
||||||
|
import io.ebean.annotation.DbDefault
|
||||||
import io.ebean.annotation.DbJsonB
|
import io.ebean.annotation.DbJsonB
|
||||||
import io.ebean.annotation.Index
|
import io.ebean.annotation.Index
|
||||||
import io.ebean.annotation.Platform
|
import io.ebean.annotation.Platform
|
||||||
@ -31,19 +32,22 @@ abstract class BaseModel : Model() {
|
|||||||
var sysPk: Long = 0
|
var sysPk: Long = 0
|
||||||
|
|
||||||
@SoftDelete
|
@SoftDelete
|
||||||
|
@DbDefault("false")
|
||||||
var deleted: Boolean = false
|
var deleted: Boolean = false
|
||||||
|
|
||||||
@Version
|
@Version
|
||||||
|
@DbDefault("1")
|
||||||
var version: Int = 0
|
var version: Int = 0
|
||||||
|
|
||||||
@WhenCreated
|
@WhenCreated
|
||||||
|
@DbDefault("now()")
|
||||||
var createdAt: LocalDateTime = LocalDateTime.now()
|
var createdAt: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
@WhenModified
|
@WhenModified
|
||||||
|
@DbDefault("now()")
|
||||||
var modifiedAt: LocalDateTime? = null
|
var modifiedAt: LocalDateTime? = null
|
||||||
|
|
||||||
@TenantId
|
|
||||||
var tenantId: String = ""
|
|
||||||
|
|
||||||
@WhoCreated
|
@WhoCreated
|
||||||
var createdBy: String = ""
|
var createdBy: String = ""
|
||||||
@ -55,22 +59,34 @@ abstract class BaseModel : Model() {
|
|||||||
|
|
||||||
var deletedBy: String? = null
|
var deletedBy: String? = null
|
||||||
|
|
||||||
|
@DbDefault("0")
|
||||||
var currentApprovalLevel: Int = 0
|
var currentApprovalLevel: Int = 0
|
||||||
|
@DbDefault("0")
|
||||||
var requiredApprovalLevels: Int = 0
|
var requiredApprovalLevels: Int = 0
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
var approvalStatus: ApprovalStatus = ApprovalStatus.PENDING
|
@DbDefault("APPROVED")
|
||||||
|
var approvalStatus: ApprovalStatus = ApprovalStatus.APPROVED
|
||||||
|
|
||||||
@DbArray
|
@DbArray
|
||||||
|
@DbDefault("{}")
|
||||||
var tags: MutableList<String> = arrayListOf()
|
var tags: MutableList<String> = arrayListOf()
|
||||||
|
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
|
@DbDefault("[]")
|
||||||
var comments: MutableList<Comments> = arrayListOf()
|
var comments: MutableList<Comments> = arrayListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@MappedSuperclass
|
||||||
|
abstract class BaseTenantModel : BaseModel() {
|
||||||
|
@TenantId
|
||||||
|
var tenantId: String = ""
|
||||||
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
open class TenantModel : BaseModel() {
|
open class TenantModel : BaseModel() {
|
||||||
|
@Index(unique = true)
|
||||||
var name: String = ""
|
var name: String = ""
|
||||||
var domain: String = ""
|
var domain: String = ""
|
||||||
var mobile: List<String> = emptyList()
|
var mobile: List<String> = emptyList()
|
||||||
@ -86,7 +102,7 @@ enum class AuditType {
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Index(columnNames = ["audit_type", "entity", "unique_identifier", "tenant_id", "created_by"])
|
@Index(columnNames = ["audit_type", "entity", "unique_identifier", "tenant_id", "created_by"])
|
||||||
open class AuditLog : BaseModel() {
|
open class AuditLog : BaseTenantModel() {
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
var auditType: AuditType = AuditType.CREATE
|
var auditType: AuditType = AuditType.CREATE
|
||||||
|
|
||||||
@ -103,39 +119,45 @@ open class AuditLog : BaseModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
open class EntityModel : BaseModel() {
|
open class EntityModel : BaseTenantModel() {
|
||||||
@Index(unique = true)
|
@Index(unique = true)
|
||||||
@JsonDeserialize(using = SafeStringDeserializer::class)
|
@JsonDeserialize(using = SafeStringDeserializer::class)
|
||||||
var name: String = ""
|
var name: String = ""
|
||||||
|
|
||||||
//a kts script that will return true/false along with errors before saving
|
//a kts script that will return true/false along with errors before saving
|
||||||
var preSaveScript: String = ""
|
var preSaveScript: String? = ""
|
||||||
|
|
||||||
//a kts script that will do something ... returns void
|
//a kts script that will do something ... returns void
|
||||||
var postSaveScript: String = ""
|
var postSaveScript: String? = ""
|
||||||
|
|
||||||
//this will create extra actions/roles in keycloak
|
//this will create extra actions/roles in keycloak
|
||||||
//the default actions are create, update, view, delete
|
//the default actions are create, update, view, delete
|
||||||
@DbArray
|
@DbArray
|
||||||
|
@DbDefault("{}")
|
||||||
var actions: List<String> = emptyList()
|
var actions: List<String> = emptyList()
|
||||||
|
|
||||||
//allow only these fields, if this is empty, then all fields are allowed
|
//allow only these fields, if this is empty, then all fields are allowed
|
||||||
@DbArray
|
@DbArray
|
||||||
|
@DbDefault("{}")
|
||||||
var allowedFields: List<String> = emptyList()
|
var allowedFields: List<String> = emptyList()
|
||||||
|
|
||||||
//enforce field types, if this is present, only fields that are present is validated
|
//enforce field types, if this is present, only fields that are present is validated
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
|
@DbDefault("{}")
|
||||||
var allowedFieldTypes: Map<String, String> = hashMapOf()
|
var allowedFieldTypes: Map<String, String> = hashMapOf()
|
||||||
|
|
||||||
//when an entity is saved/updated audit logs will be populated, when this is empty, all fields are logged
|
//when an entity is saved/updated audit logs will be populated, when this is empty, all fields are logged
|
||||||
@DbArray
|
@DbArray
|
||||||
|
@DbDefault("{}")
|
||||||
var auditLogFields: List<String> = emptyList()
|
var auditLogFields: List<String> = emptyList()
|
||||||
|
|
||||||
@DbJsonB
|
@DbJsonB
|
||||||
|
@DbDefault("{}")
|
||||||
var preferences: MutableMap<String, Any> = hashMapOf()
|
var preferences: MutableMap<String, Any> = hashMapOf()
|
||||||
|
|
||||||
//if '0' then its auto saved, no approval steps are required, for further steps,
|
//if '0' then its auto saved, no approval steps are required, for further steps,
|
||||||
//a user needs to have ROLE_ENTITY_APPROVE_LEVEL1, ROLE_ENTITY_APPROVE_LEVEL2 roles for further approvals
|
//a user needs to have ROLE_ENTITY_APPROVE_LEVEL1, ROLE_ENTITY_APPROVE_LEVEL2 roles for further approvals
|
||||||
|
@DbDefault("0")
|
||||||
var approvalLevels: Int = 0
|
var approvalLevels: Int = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +170,7 @@ enum class JobType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
open class JobModel : BaseModel() {
|
open class JobModel : BaseTenantModel() {
|
||||||
@Index(unique = true)
|
@Index(unique = true)
|
||||||
var jobName: String = ""
|
var jobName: String = ""
|
||||||
|
|
||||||
@ -168,7 +190,7 @@ open class JobModel : BaseModel() {
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Index(unique = true, name = "entity_unique_id", columnNames = ["entity_name", "unique_identifier", "tenant_id"])
|
@Index(unique = true, name = "entity_unique_id", columnNames = ["entity_name", "unique_identifier", "tenant_id"])
|
||||||
open class DataModel : BaseModel() {
|
open class DataModel : BaseTenantModel() {
|
||||||
|
|
||||||
@JsonDeserialize(using = SafeStringDeserializer::class)
|
@JsonDeserialize(using = SafeStringDeserializer::class)
|
||||||
var uniqueIdentifier: String = ""
|
var uniqueIdentifier: String = ""
|
||||||
|
|||||||
2
src/main/resources/dbmigration/1.0.1__initial_data.sql
Normal file
2
src/main/resources/dbmigration/1.0.1__initial_data.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
insert into tenant_model(name, domain, created_by, modified_by) values ('compegence', 'https://www.compegence.com', 'system', 'system');
|
||||||
|
insert into entity_model(name, tenant_id, created_by, modified_by) values ('vehicle', 'compegence', 'system', 'system');
|
||||||
@ -2,17 +2,17 @@
|
|||||||
create table audit_log (
|
create table audit_log (
|
||||||
sys_pk bigint generated by default as identity not null,
|
sys_pk bigint generated by default as identity not null,
|
||||||
deleted_on timestamp,
|
deleted_on timestamp,
|
||||||
current_approval_level integer not null,
|
current_approval_level integer default 0 not null,
|
||||||
required_approval_levels integer not null,
|
required_approval_levels integer default 0 not null,
|
||||||
deleted boolean default false not null,
|
deleted boolean default false not null,
|
||||||
version integer not null,
|
version integer default 1 not null,
|
||||||
created_at timestamp not null,
|
created_at timestamp default 'now()' not null,
|
||||||
modified_at timestamp not null,
|
modified_at timestamp default 'now()' not null,
|
||||||
tenant_id varchar(255) not null,
|
|
||||||
deleted_by varchar(255),
|
deleted_by varchar(255),
|
||||||
approval_status varchar(8) not null,
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
tags varchar[] not null,
|
tags text[] default '{}'::text[] not null,
|
||||||
comments jsonb not null,
|
comments jsonb default '[]'::jsonb not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
audit_type varchar(7) not null,
|
audit_type varchar(7) not null,
|
||||||
entity varchar(255) not null,
|
entity varchar(255) not null,
|
||||||
unique_identifier varchar(255) not null,
|
unique_identifier varchar(255) not null,
|
||||||
@ -28,17 +28,17 @@ create table audit_log (
|
|||||||
create table data_model (
|
create table data_model (
|
||||||
sys_pk bigint generated by default as identity not null,
|
sys_pk bigint generated by default as identity not null,
|
||||||
deleted_on timestamp,
|
deleted_on timestamp,
|
||||||
current_approval_level integer not null,
|
current_approval_level integer default 0 not null,
|
||||||
required_approval_levels integer not null,
|
required_approval_levels integer default 0 not null,
|
||||||
deleted boolean default false not null,
|
deleted boolean default false not null,
|
||||||
version integer not null,
|
version integer default 1 not null,
|
||||||
created_at timestamp not null,
|
created_at timestamp default 'now()' not null,
|
||||||
modified_at timestamp not null,
|
modified_at timestamp default 'now()' not null,
|
||||||
tenant_id varchar(255) not null,
|
|
||||||
deleted_by varchar(255),
|
deleted_by varchar(255),
|
||||||
approval_status varchar(8) not null,
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
tags varchar[] not null,
|
tags text[] default '{}'::text[] not null,
|
||||||
comments jsonb not null,
|
comments jsonb default '[]'::jsonb not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
unique_identifier varchar(255) not null,
|
unique_identifier varchar(255) not null,
|
||||||
entity_name varchar(255) not null,
|
entity_name varchar(255) not null,
|
||||||
data jsonb not null,
|
data jsonb not null,
|
||||||
@ -52,26 +52,26 @@ create table data_model (
|
|||||||
create table entity_model (
|
create table entity_model (
|
||||||
sys_pk bigint generated by default as identity not null,
|
sys_pk bigint generated by default as identity not null,
|
||||||
deleted_on timestamp,
|
deleted_on timestamp,
|
||||||
current_approval_level integer not null,
|
current_approval_level integer default 0 not null,
|
||||||
required_approval_levels integer not null,
|
required_approval_levels integer default 0 not null,
|
||||||
approval_levels integer not null,
|
approval_levels integer default 0 not null,
|
||||||
deleted boolean default false not null,
|
deleted boolean default false not null,
|
||||||
version integer not null,
|
version integer default 1 not null,
|
||||||
created_at timestamp not null,
|
created_at timestamp default 'now()' not null,
|
||||||
modified_at timestamp not null,
|
modified_at timestamp default 'now()' not null,
|
||||||
tenant_id varchar(255) not null,
|
|
||||||
deleted_by varchar(255),
|
deleted_by varchar(255),
|
||||||
approval_status varchar(8) not null,
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
tags varchar[] not null,
|
tags text[] default '{}'::text[] not null,
|
||||||
comments jsonb not null,
|
comments jsonb default '[]'::jsonb not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
name varchar(255) not null,
|
name varchar(255) not null,
|
||||||
pre_save_script varchar(255) not null,
|
pre_save_script varchar(255),
|
||||||
post_save_script varchar(255) not null,
|
post_save_script varchar(255),
|
||||||
actions varchar[] not null,
|
actions text[] default '{}'::text[] not null,
|
||||||
allowed_fields varchar[] not null,
|
allowed_fields text[] default '{}'::text[] not null,
|
||||||
allowed_field_types jsonb not null,
|
allowed_field_types jsonb default '{}'::jsonb not null,
|
||||||
audit_log_fields varchar[] not null,
|
audit_log_fields text[] default '{}'::text[] not null,
|
||||||
preferences jsonb not null,
|
preferences jsonb default '{}'::jsonb not null,
|
||||||
created_by varchar(255) not null,
|
created_by varchar(255) not null,
|
||||||
modified_by varchar(255) not null,
|
modified_by varchar(255) not null,
|
||||||
constraint ck_entity_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
constraint ck_entity_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
@ -82,17 +82,17 @@ create table entity_model (
|
|||||||
create table job_model (
|
create table job_model (
|
||||||
sys_pk bigint generated by default as identity not null,
|
sys_pk bigint generated by default as identity not null,
|
||||||
deleted_on timestamp,
|
deleted_on timestamp,
|
||||||
current_approval_level integer not null,
|
current_approval_level integer default 0 not null,
|
||||||
required_approval_levels integer not null,
|
required_approval_levels integer default 0 not null,
|
||||||
deleted boolean default false not null,
|
deleted boolean default false not null,
|
||||||
version integer not null,
|
version integer default 1 not null,
|
||||||
created_at timestamp not null,
|
created_at timestamp default 'now()' not null,
|
||||||
modified_at timestamp not null,
|
modified_at timestamp default 'now()' not null,
|
||||||
tenant_id varchar(255) not null,
|
|
||||||
deleted_by varchar(255),
|
deleted_by varchar(255),
|
||||||
approval_status varchar(8) not null,
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
tags varchar[] not null,
|
tags text[] default '{}'::text[] not null,
|
||||||
comments jsonb not null,
|
comments jsonb default '[]'::jsonb not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
job_name varchar(255) not null,
|
job_name varchar(255) not null,
|
||||||
job_type varchar(6) not null,
|
job_type varchar(6) not null,
|
||||||
job_path varchar(255) not null,
|
job_path varchar(255) not null,
|
||||||
@ -111,23 +111,23 @@ create table job_model (
|
|||||||
create table tenant_model (
|
create table tenant_model (
|
||||||
sys_pk bigint generated by default as identity not null,
|
sys_pk bigint generated by default as identity not null,
|
||||||
deleted_on timestamp,
|
deleted_on timestamp,
|
||||||
current_approval_level integer not null,
|
current_approval_level integer default 0 not null,
|
||||||
required_approval_levels integer not null,
|
required_approval_levels integer default 0 not null,
|
||||||
deleted boolean default false not null,
|
deleted boolean default false not null,
|
||||||
version integer not null,
|
version integer default 1 not null,
|
||||||
created_at timestamp not null,
|
created_at timestamp default 'now()' not null,
|
||||||
modified_at timestamp not null,
|
modified_at timestamp default 'now()' not null,
|
||||||
tenant_id varchar(255) not null,
|
|
||||||
deleted_by varchar(255),
|
deleted_by varchar(255),
|
||||||
approval_status varchar(8) not null,
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
tags varchar[] not null,
|
tags text[] default '{}'::text[] not null,
|
||||||
comments jsonb not null,
|
comments jsonb default '[]'::jsonb not null,
|
||||||
name varchar(255) not null,
|
name varchar(255) not null,
|
||||||
domain varchar(255) not null,
|
domain varchar(255) not null,
|
||||||
preferences jsonb not null,
|
preferences jsonb default '{}'::jsonb not null,
|
||||||
created_by varchar(255) not null,
|
created_by varchar(255) not null,
|
||||||
modified_by varchar(255) not null,
|
modified_by varchar(255) not null,
|
||||||
constraint ck_tenant_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
constraint ck_tenant_model_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
|
constraint uq_tenant_model_name unique (name),
|
||||||
constraint pk_tenant_model primary key (sys_pk)
|
constraint pk_tenant_model primary key (sys_pk)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -136,3 +136,6 @@ create index if not exists ix_audit_log_audit_type_entity_unique_identifier_tena
|
|||||||
create index audit_log_values_idx on audit_log using GIN (data);
|
create index audit_log_values_idx on audit_log using GIN (data);
|
||||||
create index audit_log_changes_idx on audit_log using GIN (changes);
|
create index audit_log_changes_idx on audit_log using GIN (changes);
|
||||||
create index data_jsonb_idx on data_model using GIN (data) ;
|
create index data_jsonb_idx on data_model using GIN (data) ;
|
||||||
|
|
||||||
|
ALTER TABLE data_model ADD FOREIGN KEY(tenant_id) REFERENCES tenant_model(name);
|
||||||
|
ALTER TABLE data_model ADD FOREIGN KEY(entity_name) REFERENCES entity_model(name);
|
||||||
@ -3,84 +3,84 @@
|
|||||||
<changeSet type="apply">
|
<changeSet type="apply">
|
||||||
<createTable name="audit_log" pkName="pk_audit_log">
|
<createTable name="audit_log" pkName="pk_audit_log">
|
||||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
|
||||||
<column name="deleted_on" type="localdatetime"/>
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
<column name="deleted_by" type="varchar"/>
|
<column name="deleted_by" type="varchar"/>
|
||||||
<column name="current_approval_level" type="integer" notnull="true"/>
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="required_approval_levels" type="integer" notnull="true"/>
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="approval_status" type="varchar(8)" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_audit_log_approval_status"/>
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_audit_log_approval_status"/>
|
||||||
<column name="tags" type="varchar[]" notnull="true"/>
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="comments" type="jsonb" notnull="true"/>
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
|
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||||
<column name="audit_type" type="varchar(7)" notnull="true" checkConstraint="check ( audit_type in ('CREATE','UPDATE','DELETE','VIEW','APPROVE','REJECT'))" checkConstraintName="ck_audit_log_audit_type"/>
|
<column name="audit_type" type="varchar(7)" notnull="true" checkConstraint="check ( audit_type in ('CREATE','UPDATE','DELETE','VIEW','APPROVE','REJECT'))" checkConstraintName="ck_audit_log_audit_type"/>
|
||||||
<column name="entity" type="varchar" notnull="true"/>
|
<column name="entity" type="varchar" notnull="true"/>
|
||||||
<column name="unique_identifier" type="varchar" notnull="true"/>
|
<column name="unique_identifier" type="varchar" notnull="true"/>
|
||||||
<column name="data" type="jsonb" notnull="true"/>
|
<column name="data" type="jsonb" notnull="true"/>
|
||||||
<column name="changes" type="jsonb" notnull="true"/>
|
<column name="changes" type="jsonb" notnull="true"/>
|
||||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
<column name="version" type="integer" notnull="true"/>
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
<column name="created_at" type="localdatetime" notnull="true"/>
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="modified_at" type="localdatetime" notnull="true"/>
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="created_by" type="varchar" notnull="true"/>
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
<column name="modified_by" type="varchar" notnull="true"/>
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="data_model" pkName="pk_data_model">
|
<createTable name="data_model" pkName="pk_data_model">
|
||||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
|
||||||
<column name="deleted_on" type="localdatetime"/>
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
<column name="deleted_by" type="varchar"/>
|
<column name="deleted_by" type="varchar"/>
|
||||||
<column name="current_approval_level" type="integer" notnull="true"/>
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="required_approval_levels" type="integer" notnull="true"/>
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="approval_status" type="varchar(8)" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_data_model_approval_status"/>
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_data_model_approval_status"/>
|
||||||
<column name="tags" type="varchar[]" notnull="true"/>
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="comments" type="jsonb" notnull="true"/>
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
|
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||||
<column name="unique_identifier" type="varchar" notnull="true"/>
|
<column name="unique_identifier" type="varchar" notnull="true"/>
|
||||||
<column name="entity_name" type="varchar" notnull="true"/>
|
<column name="entity_name" type="varchar" notnull="true"/>
|
||||||
<column name="data" type="jsonb" notnull="true"/>
|
<column name="data" type="jsonb" notnull="true"/>
|
||||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
<column name="version" type="integer" notnull="true"/>
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
<column name="created_at" type="localdatetime" notnull="true"/>
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="modified_at" type="localdatetime" notnull="true"/>
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="created_by" type="varchar" notnull="true"/>
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
<column name="modified_by" type="varchar" notnull="true"/>
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
<uniqueConstraint name="entity_unique_id" columnNames="entity_name,unique_identifier,tenant_id" oneToOne="false" nullableColumns=""/>
|
<uniqueConstraint name="entity_unique_id" columnNames="entity_name,unique_identifier,tenant_id" oneToOne="false" nullableColumns=""/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="entity_model" pkName="pk_entity_model">
|
<createTable name="entity_model" pkName="pk_entity_model">
|
||||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
|
||||||
<column name="deleted_on" type="localdatetime"/>
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
<column name="deleted_by" type="varchar"/>
|
<column name="deleted_by" type="varchar"/>
|
||||||
<column name="current_approval_level" type="integer" notnull="true"/>
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="required_approval_levels" type="integer" notnull="true"/>
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="approval_status" type="varchar(8)" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_entity_model_approval_status"/>
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_entity_model_approval_status"/>
|
||||||
<column name="tags" type="varchar[]" notnull="true"/>
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="comments" type="jsonb" notnull="true"/>
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
|
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||||
<column name="name" type="varchar" notnull="true"/>
|
<column name="name" type="varchar" notnull="true"/>
|
||||||
<column name="pre_save_script" type="varchar" notnull="true"/>
|
<column name="pre_save_script" type="varchar"/>
|
||||||
<column name="post_save_script" type="varchar" notnull="true"/>
|
<column name="post_save_script" type="varchar"/>
|
||||||
<column name="actions" type="varchar[]" notnull="true"/>
|
<column name="actions" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="allowed_fields" type="varchar[]" notnull="true"/>
|
<column name="allowed_fields" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="allowed_field_types" type="jsonb" notnull="true"/>
|
<column name="allowed_field_types" type="jsonb" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="audit_log_fields" type="varchar[]" notnull="true"/>
|
<column name="audit_log_fields" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="preferences" type="jsonb" notnull="true"/>
|
<column name="preferences" type="jsonb" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="approval_levels" type="integer" notnull="true"/>
|
<column name="approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
<column name="version" type="integer" notnull="true"/>
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
<column name="created_at" type="localdatetime" notnull="true"/>
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="modified_at" type="localdatetime" notnull="true"/>
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="created_by" type="varchar" notnull="true"/>
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
<column name="modified_by" type="varchar" notnull="true"/>
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
<uniqueConstraint name="uq_entity_model_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
<uniqueConstraint name="uq_entity_model_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="job_model" pkName="pk_job_model">
|
<createTable name="job_model" pkName="pk_job_model">
|
||||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
|
||||||
<column name="deleted_on" type="localdatetime"/>
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
<column name="deleted_by" type="varchar"/>
|
<column name="deleted_by" type="varchar"/>
|
||||||
<column name="current_approval_level" type="integer" notnull="true"/>
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="required_approval_levels" type="integer" notnull="true"/>
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="approval_status" type="varchar(8)" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_job_model_approval_status"/>
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_job_model_approval_status"/>
|
||||||
<column name="tags" type="varchar[]" notnull="true"/>
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="comments" type="jsonb" notnull="true"/>
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
|
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||||
<column name="job_name" type="varchar" notnull="true"/>
|
<column name="job_name" type="varchar" notnull="true"/>
|
||||||
<column name="job_type" type="varchar(6)" notnull="true" checkConstraint="check ( job_type in ('SCRIPT','DB'))" checkConstraintName="ck_job_model_job_type"/>
|
<column name="job_type" type="varchar(6)" notnull="true" checkConstraint="check ( job_type in ('SCRIPT','DB'))" checkConstraintName="ck_job_model_job_type"/>
|
||||||
<column name="job_path" type="varchar" notnull="true"/>
|
<column name="job_path" type="varchar" notnull="true"/>
|
||||||
@ -88,32 +88,32 @@
|
|||||||
<column name="job_frequency_type" type="varchar(8)" notnull="true" checkConstraint="check ( job_frequency_type in ('SPECIFIC','EVERY','CRON'))" checkConstraintName="ck_job_model_job_frequency_type"/>
|
<column name="job_frequency_type" type="varchar(8)" notnull="true" checkConstraint="check ( job_frequency_type in ('SPECIFIC','EVERY','CRON'))" checkConstraintName="ck_job_model_job_frequency_type"/>
|
||||||
<column name="frequency" type="varchar" notnull="true"/>
|
<column name="frequency" type="varchar" notnull="true"/>
|
||||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
<column name="version" type="integer" notnull="true"/>
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
<column name="created_at" type="localdatetime" notnull="true"/>
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="modified_at" type="localdatetime" notnull="true"/>
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="created_by" type="varchar" notnull="true"/>
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
<column name="modified_by" type="varchar" notnull="true"/>
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
<uniqueConstraint name="uq_job_model_job_name" columnNames="job_name" oneToOne="false" nullableColumns=""/>
|
<uniqueConstraint name="uq_job_model_job_name" columnNames="job_name" oneToOne="false" nullableColumns=""/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createTable name="tenant_model" pkName="pk_tenant_model">
|
<createTable name="tenant_model" pkName="pk_tenant_model">
|
||||||
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
<column name="tenant_id" type="varchar" notnull="true"/>
|
|
||||||
<column name="deleted_on" type="localdatetime"/>
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
<column name="deleted_by" type="varchar"/>
|
<column name="deleted_by" type="varchar"/>
|
||||||
<column name="current_approval_level" type="integer" notnull="true"/>
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="required_approval_levels" type="integer" notnull="true"/>
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
<column name="approval_status" type="varchar(8)" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_tenant_model_approval_status"/>
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_tenant_model_approval_status"/>
|
||||||
<column name="tags" type="varchar[]" notnull="true"/>
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
<column name="comments" type="jsonb" notnull="true"/>
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
<column name="name" type="varchar" notnull="true"/>
|
<column name="name" type="varchar" notnull="true"/>
|
||||||
<column name="domain" type="varchar" notnull="true"/>
|
<column name="domain" type="varchar" notnull="true"/>
|
||||||
<column name="preferences" type="jsonb" notnull="true"/>
|
<column name="preferences" type="jsonb" notnull="true"/>
|
||||||
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
<column name="version" type="integer" notnull="true"/>
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
<column name="created_at" type="localdatetime" notnull="true"/>
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="modified_at" type="localdatetime" notnull="true"/>
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
<column name="created_by" type="varchar" notnull="true"/>
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
<column name="modified_by" type="varchar" notnull="true"/>
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
|
<uniqueConstraint name="uq_tenant_model_name" columnNames="name" oneToOne="false" nullableColumns=""/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<createIndex indexName="ix_audit_log_audit_type_entity_unique_identifier_tenant_i_1" tableName="audit_log" columns="audit_type,entity,unique_identifier,tenant_id,created_by"/>
|
<createIndex indexName="ix_audit_log_audit_type_entity_unique_identifier_tenant_i_1" tableName="audit_log" columns="audit_type,entity,unique_identifier,tenant_id,created_by"/>
|
||||||
<createIndex indexName="ix_audit_log_data" tableName="audit_log" columns="data" definition="create index audit_log_values_idx on audit_log using GIN (data)" platforms="POSTGRES"/>
|
<createIndex indexName="ix_audit_log_data" tableName="audit_log" columns="data" definition="create index audit_log_values_idx on audit_log using GIN (data)" platforms="POSTGRES"/>
|
||||||
|
|||||||
24
src/main/resources/extra-ddl.xml
Normal file
24
src/main/resources/extra-ddl.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<extra-ddl xmlns="http://ebean-orm.github.io/xml/ns/extraddl">
|
||||||
|
|
||||||
|
<!--<ddl-script name="1 product view">
|
||||||
|
drop view if exists product_vw cascade;
|
||||||
|
|
||||||
|
create view product_vw as
|
||||||
|
...;
|
||||||
|
</ddl-script>
|
||||||
|
|
||||||
|
<ddl-script name="2 promotion views">
|
||||||
|
-- 2 related/dependent views that drop and create together
|
||||||
|
|
||||||
|
drop view if exists promotion_minprice_vw cascade;
|
||||||
|
drop view if exists promotion_vw cascade;
|
||||||
|
|
||||||
|
create view promotion_vw as
|
||||||
|
...;
|
||||||
|
|
||||||
|
create view promotion_minprice_vw as
|
||||||
|
...;
|
||||||
|
</ddl-script>-->
|
||||||
|
|
||||||
|
</extra-ddl>
|
||||||
21
src/main/resources/logback.xml
Normal file
21
src/main/resources/logback.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- SQL and bind values -->
|
||||||
|
<logger name="io.ebean.SQL" level="TRACE"/>
|
||||||
|
|
||||||
|
<!-- Transaction Commit and Rollback events -->
|
||||||
|
<logger name="io.ebean.TXN" level="WARN"/>
|
||||||
|
<logger name="io.ebean.SUM" level="WARN"/>
|
||||||
|
<logger name="io.ebean.migration" level="TRACE"/>
|
||||||
|
<logger name="io.ebean.dbmigration" level="TRACE"/>
|
||||||
|
<logger name="io.ebean" level="TRACE"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
||||||
Loading…
x
Reference in New Issue
Block a user