add entities and db migrations
This commit is contained in:
parent
1abf482a7a
commit
f440ca89f3
18
.idea/dataSources.xml
generated
18
.idea/dataSources.xml
generated
@ -6,6 +6,24 @@
|
|||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
<jdbc-url>jdbc:postgresql://192.168.64.6:5432/uiapp</jdbc-url>
|
<jdbc-url>jdbc:postgresql://192.168.64.6:5432/uiapp</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="arsalan_rmc_module_app@10.10.10.211" uuid="572880af-561c-4a5a-90bd-e024c09c674b">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql://10.10.10.211:5432/arsalan_rmc_module_app</jdbc-url>
|
||||||
|
<jdbc-additional-properties>
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.host.port" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
|
||||||
|
<property name="com.intellij.clouds.kubernetes.db.container.port" />
|
||||||
|
</jdbc-additional-properties>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,8 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$/../rmc-modules-app" vcs="Git" />
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/../txn_workflow" vcs="Git" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
30
api.http
30
api.http
@ -8,7 +8,19 @@ Authorization: {{auth-token}}
|
|||||||
"number": "KA01HD6667",
|
"number": "KA01HD6667",
|
||||||
"owner": "gowthaman"
|
"owner": "gowthaman"
|
||||||
},
|
},
|
||||||
"uniqueIdentifier": "KA01HD6667"
|
"uniqueIdentifier": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
### create row
|
||||||
|
POST http://localhost:9001/api/vendor
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"name": "arsalan",
|
||||||
|
"rating": 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
### create row, with autogenerated identifier
|
### create row, with autogenerated identifier
|
||||||
@ -23,6 +35,18 @@ Authorization: {{auth-token}}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### create row, with autogenerated identifier
|
||||||
|
POST http://localhost:9001/api/purchaseOrder
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"vendor" : "arslan",
|
||||||
|
"products": ["chairs", "tables"]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### get row
|
### get row
|
||||||
GET http://localhost:9001/api/log/log-0000000001
|
GET http://localhost:9001/api/log/log-0000000001
|
||||||
Authorization: Bearer {{auth-token}}
|
Authorization: Bearer {{auth-token}}
|
||||||
@ -67,4 +91,8 @@ Authorization: {{auth-token}}
|
|||||||
|
|
||||||
### delete a row
|
### delete a row
|
||||||
DELETE http://localhost:9001/api/vehicle/KA01HD6667
|
DELETE http://localhost:9001/api/vehicle/KA01HD6667
|
||||||
|
Authorization: {{auth-token}}
|
||||||
|
|
||||||
|
### get po for id
|
||||||
|
GET http://localhost:9001/api/vendor/po/12345
|
||||||
Authorization: {{auth-token}}
|
Authorization: {{auth-token}}
|
||||||
@ -19,6 +19,7 @@ app:
|
|||||||
scripts:
|
scripts:
|
||||||
path: /Users/gowthaman.b/IdeaProjects/rmc_modules_api/src/main/resources/scripts
|
path: /Users/gowthaman.b/IdeaProjects/rmc_modules_api/src/main/resources/scripts
|
||||||
security:
|
security:
|
||||||
|
enforce_role_restriction: 'true'
|
||||||
private_key: |-
|
private_key: |-
|
||||||
-----BEGIN PRIVATE KEY-----
|
-----BEGIN PRIVATE KEY-----
|
||||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD4ba8OhlyB9MUx
|
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD4ba8OhlyB9MUx
|
||||||
|
|||||||
@ -42,6 +42,7 @@ class AppAccessManager : AccessManager {
|
|||||||
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 -> role.action.toList().map { "ROLE_${entity}_${it}" }
|
is Role.Standard -> role.action.toList().map { "ROLE_${entity}_${it}" }
|
||||||
|
is Role.Explicit -> role.roles
|
||||||
}.map(String::uppercase)
|
}.map(String::uppercase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import com.restapi.config.*
|
|||||||
import com.restapi.config.AppConfig.Companion.appConfig
|
import com.restapi.config.AppConfig.Companion.appConfig
|
||||||
import com.restapi.config.Auth.validateAuthToken
|
import com.restapi.config.Auth.validateAuthToken
|
||||||
import com.restapi.controllers.Entities
|
import com.restapi.controllers.Entities
|
||||||
|
import com.restapi.controllers.PurchaseOrder
|
||||||
import com.restapi.domain.DataNotFoundException
|
import com.restapi.domain.DataNotFoundException
|
||||||
import com.restapi.domain.Session
|
import com.restapi.domain.Session
|
||||||
import com.restapi.domain.Session.currentTenant
|
import com.restapi.domain.Session.currentTenant
|
||||||
@ -22,6 +23,7 @@ import io.javalin.http.UnauthorizedResponse
|
|||||||
import io.javalin.http.util.NaiveRateLimit
|
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 org.checkerframework.dataflow.qual.Pure
|
||||||
import org.jose4j.jwt.consumer.InvalidJwtException
|
import org.jose4j.jwt.consumer.InvalidJwtException
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
@ -111,6 +113,12 @@ fun main(args: Array<String>) {
|
|||||||
it.json(mapOf("status" to true))
|
it.json(mapOf("status" to true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path("/vendor"){
|
||||||
|
path("/po"){
|
||||||
|
post("", PurchaseOrder::create, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_ADMIN"))))
|
||||||
|
get("/{id}", PurchaseOrder::get, Roles(Role.Explicit(listOf("ROLE_PO_CREATE", "ROLE_PO_VIEW", "ROLE_QUOTE_CREATE"))))
|
||||||
|
}
|
||||||
|
}
|
||||||
post("/script/database/{name}", Entities::executeStoredProcedure, Roles(adminRole, Role.DbOps))
|
post("/script/database/{name}", Entities::executeStoredProcedure, Roles(adminRole, Role.DbOps))
|
||||||
post("/script/{file}/{name}", Entities::executeScript, Roles(adminRole, Role.DbOps))
|
post("/script/{file}/{name}", Entities::executeScript, Roles(adminRole, Role.DbOps))
|
||||||
|
|
||||||
|
|||||||
@ -235,6 +235,7 @@ enum class Action {
|
|||||||
sealed class Role {
|
sealed class Role {
|
||||||
open class Standard(vararg val action: Action) : Role()
|
open class Standard(vararg val action: Action) : Role()
|
||||||
data object Entity : Role()
|
data object Entity : Role()
|
||||||
|
data class Explicit(val roles: List<String>) : Role()
|
||||||
data object DbOps : Role()
|
data object DbOps : Role()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.JsonDeserializer
|
|||||||
import com.fasterxml.jackson.databind.JsonNode
|
import com.fasterxml.jackson.databind.JsonNode
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
||||||
import com.restapi.domain.*
|
import com.restapi.domain.*
|
||||||
|
import com.restapi.domain.PurchaseOrder
|
||||||
import com.restapi.domain.Session.currentUser
|
import com.restapi.domain.Session.currentUser
|
||||||
import com.restapi.domain.Session.database
|
import com.restapi.domain.Session.database
|
||||||
import com.restapi.domain.Session.findDataModelByEntityAndUniqId
|
import com.restapi.domain.Session.findDataModelByEntityAndUniqId
|
||||||
@ -371,4 +372,17 @@ object Entities {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object PurchaseOrder {
|
||||||
|
fun get(ctx :Context){
|
||||||
|
val id = ctx.pathParam("id")
|
||||||
|
val po = database.find(PurchaseOrder::class.java, id) ?: throw NotFoundResponse("po not found for $id")
|
||||||
|
|
||||||
|
ctx.json(po)
|
||||||
|
}
|
||||||
|
fun create(ctx :Context){
|
||||||
|
val po = ctx.bodyAsClass<PurchaseOrder>()
|
||||||
|
database.save(po)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -7,11 +7,12 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
|
|||||||
import io.ebean.Model
|
import io.ebean.Model
|
||||||
import io.ebean.annotation.*
|
import io.ebean.annotation.*
|
||||||
import io.ebean.annotation.Index
|
import io.ebean.annotation.Index
|
||||||
|
import java.time.LocalDate
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
|
|
||||||
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
||||||
|
data class POProducts(val productId: String = "", val unitPrice :Double = 0.0, val quantity: Double = 0.0, val description :String = "")
|
||||||
enum class ApprovalStatus {
|
enum class ApprovalStatus {
|
||||||
PENDING, APPROVED, REJECTED
|
PENDING, APPROVED, REJECTED
|
||||||
}
|
}
|
||||||
@ -214,6 +215,8 @@ open class DataModel : BaseTenantModel() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Index(unique = true, name = "unique_session_id", columnNames = ["session_id"])
|
@Index(unique = true, name = "unique_session_id", columnNames = ["session_id"])
|
||||||
open class AnonSession : BaseTenantModel() {
|
open class AnonSession : BaseTenantModel() {
|
||||||
@ -238,3 +241,69 @@ class SafeStringDeserializer : JsonDeserializer<String>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class ContactPerson(val name: String, val email: String, val mobile: String)
|
||||||
|
@Entity
|
||||||
|
open class Vendor :BaseTenantModel() {
|
||||||
|
var name :String = ""
|
||||||
|
var msme :String = ""
|
||||||
|
var gstNumber :String = ""
|
||||||
|
var address :String = ""
|
||||||
|
var rating :Double = 0.0
|
||||||
|
@DbJsonB
|
||||||
|
var contacts :List<ContactPerson> = mutableListOf()
|
||||||
|
}
|
||||||
|
@Entity
|
||||||
|
open class PurchaseOrder :BaseTenantModel() {
|
||||||
|
@DbJsonB
|
||||||
|
var products :MutableList<POProducts> = mutableListOf()
|
||||||
|
@ManyToOne
|
||||||
|
var vendor :Vendor? = null
|
||||||
|
var referenceQuotation :String = ""
|
||||||
|
var totalAmount :Int = 0
|
||||||
|
var poNum: String = ""
|
||||||
|
var poDate: LocalDate? = null
|
||||||
|
var validTill: LocalDate? = null
|
||||||
|
@DbArray
|
||||||
|
var tnc: List<String> = arrayListOf()
|
||||||
|
@DbArray
|
||||||
|
var documents: MutableList<Long> = arrayListOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class UOM {
|
||||||
|
NOS, LTR, MTR
|
||||||
|
}
|
||||||
|
@Entity
|
||||||
|
open class Product :BaseTenantModel() {
|
||||||
|
var name :String = ""
|
||||||
|
var description :String = ""
|
||||||
|
var hsnCode :String = ""
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
var uom: UOM? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
open class Quotation :BaseTenantModel() {
|
||||||
|
@DbJsonB
|
||||||
|
var products :MutableList<POProducts> = mutableListOf()
|
||||||
|
@ManyToOne
|
||||||
|
var vendor :Vendor? = null
|
||||||
|
var totalAmount :Int = 0
|
||||||
|
|
||||||
|
var quoteNum: String = ""
|
||||||
|
var quoteDate: LocalDate? = null
|
||||||
|
var validTill: LocalDate? = null
|
||||||
|
@DbArray
|
||||||
|
var tnc: List<String> = arrayListOf()
|
||||||
|
|
||||||
|
@DbArray
|
||||||
|
var documents: MutableList<Long> = arrayListOf()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
open class Document :BaseTenantModel() {
|
||||||
|
var name :String = ""
|
||||||
|
var typeOfDoc :String = ""
|
||||||
|
var description :String = ""
|
||||||
|
var url :String = ""
|
||||||
|
}
|
||||||
140
src/main/resources/dbmigration/1.2.sql
Normal file
140
src/main/resources/dbmigration/1.2.sql
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
-- apply changes
|
||||||
|
create table document (
|
||||||
|
sys_pk bigint generated by default as identity not null,
|
||||||
|
deleted_on timestamp,
|
||||||
|
current_approval_level integer default 0 not null,
|
||||||
|
required_approval_levels integer default 0 not null,
|
||||||
|
deleted boolean default false not null,
|
||||||
|
version integer default 1 not null,
|
||||||
|
created_at timestamp default 'now()' not null,
|
||||||
|
modified_at timestamp default 'now()' not null,
|
||||||
|
deleted_by varchar(255),
|
||||||
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
|
tags varchar[] default '{}' not null,
|
||||||
|
comments jsonb default '[]' not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
|
name varchar(255) not null,
|
||||||
|
type_of_doc varchar(255) not null,
|
||||||
|
description varchar(255) not null,
|
||||||
|
url varchar(255) not null,
|
||||||
|
created_by varchar(255) not null,
|
||||||
|
modified_by varchar(255) not null,
|
||||||
|
constraint ck_document_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
|
constraint pk_document primary key (sys_pk)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table product (
|
||||||
|
sys_pk bigint generated by default as identity not null,
|
||||||
|
deleted_on timestamp,
|
||||||
|
current_approval_level integer default 0 not null,
|
||||||
|
required_approval_levels integer default 0 not null,
|
||||||
|
deleted boolean default false not null,
|
||||||
|
version integer default 1 not null,
|
||||||
|
created_at timestamp default 'now()' not null,
|
||||||
|
modified_at timestamp default 'now()' not null,
|
||||||
|
deleted_by varchar(255),
|
||||||
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
|
tags varchar[] default '{}' not null,
|
||||||
|
comments jsonb default '[]' not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
|
name varchar(255) not null,
|
||||||
|
description varchar(255) not null,
|
||||||
|
hsn_code varchar(255) not null,
|
||||||
|
uom varchar(3),
|
||||||
|
created_by varchar(255) not null,
|
||||||
|
modified_by varchar(255) not null,
|
||||||
|
constraint ck_product_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
|
constraint ck_product_uom check ( uom in ('NOS','LTR','MTR')),
|
||||||
|
constraint pk_product primary key (sys_pk)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table purchase_order (
|
||||||
|
sys_pk bigint generated by default as identity not null,
|
||||||
|
deleted_on timestamp,
|
||||||
|
current_approval_level integer default 0 not null,
|
||||||
|
required_approval_levels integer default 0 not null,
|
||||||
|
vendor_sys_pk bigint,
|
||||||
|
total_amount integer not null,
|
||||||
|
po_date date,
|
||||||
|
valid_till date,
|
||||||
|
documents bigint[] not null,
|
||||||
|
deleted boolean default false not null,
|
||||||
|
version integer default 1 not null,
|
||||||
|
created_at timestamp default 'now()' not null,
|
||||||
|
modified_at timestamp default 'now()' not null,
|
||||||
|
deleted_by varchar(255),
|
||||||
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
|
tags varchar[] default '{}' not null,
|
||||||
|
comments jsonb default '[]' not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
|
products jsonb not null,
|
||||||
|
reference_quotation varchar(255) not null,
|
||||||
|
po_num varchar(255) not null,
|
||||||
|
tnc varchar[] not null,
|
||||||
|
created_by varchar(255) not null,
|
||||||
|
modified_by varchar(255) not null,
|
||||||
|
constraint ck_purchase_order_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
|
constraint pk_purchase_order primary key (sys_pk)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table quotation (
|
||||||
|
sys_pk bigint generated by default as identity not null,
|
||||||
|
deleted_on timestamp,
|
||||||
|
current_approval_level integer default 0 not null,
|
||||||
|
required_approval_levels integer default 0 not null,
|
||||||
|
vendor_sys_pk bigint,
|
||||||
|
total_amount integer not null,
|
||||||
|
quote_date date,
|
||||||
|
valid_till date,
|
||||||
|
documents bigint[] not null,
|
||||||
|
deleted boolean default false not null,
|
||||||
|
version integer default 1 not null,
|
||||||
|
created_at timestamp default 'now()' not null,
|
||||||
|
modified_at timestamp default 'now()' not null,
|
||||||
|
deleted_by varchar(255),
|
||||||
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
|
tags varchar[] default '{}' not null,
|
||||||
|
comments jsonb default '[]' not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
|
products jsonb not null,
|
||||||
|
quote_num varchar(255) not null,
|
||||||
|
tnc varchar[] not null,
|
||||||
|
created_by varchar(255) not null,
|
||||||
|
modified_by varchar(255) not null,
|
||||||
|
constraint ck_quotation_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
|
constraint pk_quotation primary key (sys_pk)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table vendor (
|
||||||
|
sys_pk bigint generated by default as identity not null,
|
||||||
|
deleted_on timestamp,
|
||||||
|
current_approval_level integer default 0 not null,
|
||||||
|
required_approval_levels integer default 0 not null,
|
||||||
|
rating float not null,
|
||||||
|
deleted boolean default false not null,
|
||||||
|
version integer default 1 not null,
|
||||||
|
created_at timestamp default 'now()' not null,
|
||||||
|
modified_at timestamp default 'now()' not null,
|
||||||
|
deleted_by varchar(255),
|
||||||
|
approval_status varchar(8) default 'APPROVED' not null,
|
||||||
|
tags varchar[] default '{}' not null,
|
||||||
|
comments jsonb default '[]' not null,
|
||||||
|
tenant_id varchar(255) not null,
|
||||||
|
name varchar(255) not null,
|
||||||
|
msme varchar(255) not null,
|
||||||
|
gst_number varchar(255) not null,
|
||||||
|
address varchar(255) not null,
|
||||||
|
contacts jsonb not null,
|
||||||
|
created_by varchar(255) not null,
|
||||||
|
modified_by varchar(255) not null,
|
||||||
|
constraint ck_vendor_approval_status check ( approval_status in ('PENDING','APPROVED','REJECTED')),
|
||||||
|
constraint pk_vendor primary key (sys_pk)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- foreign keys and indices
|
||||||
|
create index ix_purchase_order_vendor_sys_pk on purchase_order (vendor_sys_pk);
|
||||||
|
alter table purchase_order add constraint fk_purchase_order_vendor_sys_pk foreign key (vendor_sys_pk) references vendor (sys_pk) on delete restrict on update restrict;
|
||||||
|
|
||||||
|
create index ix_quotation_vendor_sys_pk on quotation (vendor_sys_pk);
|
||||||
|
alter table quotation add constraint fk_quotation_vendor_sys_pk foreign key (vendor_sys_pk) references vendor (sys_pk) on delete restrict on update restrict;
|
||||||
|
|
||||||
121
src/main/resources/dbmigration/model/1.2.model.xml
Normal file
121
src/main/resources/dbmigration/model/1.2.model.xml
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||||
|
<changeSet type="apply">
|
||||||
|
<createTable name="document" pkName="pk_document">
|
||||||
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
|
<column name="deleted_by" type="varchar"/>
|
||||||
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_document_approval_status"/>
|
||||||
|
<column name="tags" type="varchar[]" defaultValue="'{}'" 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="type_of_doc" type="varchar" notnull="true"/>
|
||||||
|
<column name="description" type="varchar" notnull="true"/>
|
||||||
|
<column name="url" type="varchar" notnull="true"/>
|
||||||
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
|
</createTable>
|
||||||
|
<createTable name="product" pkName="pk_product">
|
||||||
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
|
<column name="deleted_by" type="varchar"/>
|
||||||
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_product_approval_status"/>
|
||||||
|
<column name="tags" type="varchar[]" defaultValue="'{}'" 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="description" type="varchar" notnull="true"/>
|
||||||
|
<column name="hsn_code" type="varchar" notnull="true"/>
|
||||||
|
<column name="uom" type="varchar(3)" checkConstraint="check ( uom in ('NOS','LTR','MTR'))" checkConstraintName="ck_product_uom"/>
|
||||||
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
|
</createTable>
|
||||||
|
<createTable name="purchase_order" pkName="pk_purchase_order">
|
||||||
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
|
<column name="deleted_by" type="varchar"/>
|
||||||
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_purchase_order_approval_status"/>
|
||||||
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
|
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||||
|
<column name="products" type="jsonb" notnull="true"/>
|
||||||
|
<column name="vendor_sys_pk" type="bigint" references="vendor.sys_pk" foreignKeyName="fk_purchase_order_vendor_sys_pk" foreignKeyIndex="ix_purchase_order_vendor_sys_pk"/>
|
||||||
|
<column name="reference_quotation" type="varchar" notnull="true"/>
|
||||||
|
<column name="total_amount" type="integer" notnull="true"/>
|
||||||
|
<column name="po_num" type="varchar" notnull="true"/>
|
||||||
|
<column name="po_date" type="date"/>
|
||||||
|
<column name="valid_till" type="date"/>
|
||||||
|
<column name="tnc" type="varchar[]" notnull="true"/>
|
||||||
|
<column name="documents" type="bigint[]" notnull="true"/>
|
||||||
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
|
</createTable>
|
||||||
|
<createTable name="quotation" pkName="pk_quotation">
|
||||||
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
|
<column name="deleted_by" type="varchar"/>
|
||||||
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_quotation_approval_status"/>
|
||||||
|
<column name="tags" type="varchar[]" defaultValue="'{}'" notnull="true"/>
|
||||||
|
<column name="comments" type="jsonb" defaultValue="'[]'" notnull="true"/>
|
||||||
|
<column name="tenant_id" type="varchar" notnull="true"/>
|
||||||
|
<column name="products" type="jsonb" notnull="true"/>
|
||||||
|
<column name="vendor_sys_pk" type="bigint" references="vendor.sys_pk" foreignKeyName="fk_quotation_vendor_sys_pk" foreignKeyIndex="ix_quotation_vendor_sys_pk"/>
|
||||||
|
<column name="total_amount" type="integer" notnull="true"/>
|
||||||
|
<column name="quote_num" type="varchar" notnull="true"/>
|
||||||
|
<column name="quote_date" type="date"/>
|
||||||
|
<column name="valid_till" type="date"/>
|
||||||
|
<column name="tnc" type="varchar[]" notnull="true"/>
|
||||||
|
<column name="documents" type="bigint[]" notnull="true"/>
|
||||||
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
|
</createTable>
|
||||||
|
<createTable name="vendor" pkName="pk_vendor">
|
||||||
|
<column name="sys_pk" type="bigint" primaryKey="true"/>
|
||||||
|
<column name="deleted_on" type="localdatetime"/>
|
||||||
|
<column name="deleted_by" type="varchar"/>
|
||||||
|
<column name="current_approval_level" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="required_approval_levels" type="integer" defaultValue="0" notnull="true"/>
|
||||||
|
<column name="approval_status" type="varchar(8)" defaultValue="'APPROVED'" notnull="true" checkConstraint="check ( approval_status in ('PENDING','APPROVED','REJECTED'))" checkConstraintName="ck_vendor_approval_status"/>
|
||||||
|
<column name="tags" type="varchar[]" defaultValue="'{}'" 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="msme" type="varchar" notnull="true"/>
|
||||||
|
<column name="gst_number" type="varchar" notnull="true"/>
|
||||||
|
<column name="address" type="varchar" notnull="true"/>
|
||||||
|
<column name="rating" type="double" notnull="true"/>
|
||||||
|
<column name="contacts" type="jsonb" notnull="true"/>
|
||||||
|
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
|
||||||
|
<column name="version" type="integer" defaultValue="1" notnull="true"/>
|
||||||
|
<column name="created_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="modified_at" type="localdatetime" defaultValue="'now()'" notnull="true"/>
|
||||||
|
<column name="created_by" type="varchar" notnull="true"/>
|
||||||
|
<column name="modified_by" type="varchar" notnull="true"/>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</migration>
|
||||||
Loading…
x
Reference in New Issue
Block a user