aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrfoxygmfr <mrfoxygmfr@sch9.ru>2025-03-17 12:58:57 +0300
committermrfoxygmfr <mrfoxygmfr@sch9.ru>2025-03-17 12:58:57 +0300
commitcad2254f0eaf770a169432296916a2acafe18b4a (patch)
treec433d43019b1988e1fa2a797439eae8381f24e9d
parentc89e43daf441f245fc1ae114d0723e6e42c3f52a (diff)
fix(db): remove enum dictionary tables
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java2
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java2
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java2
-rw-r--r--src/main/sql/1_create-database.down.sql5
-rw-r--r--src/main/sql/1_create-database.up.sql21
5 files changed, 7 insertions, 25 deletions
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java
index 6409b55..72c2353 100644
--- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java
@@ -30,7 +30,7 @@ public class Operation {
private OperationType type;
@Column(nullable = false, name = "status")
- @Enumerated(EnumType.ORDINAL)
+ @Enumerated(EnumType.STRING)
@NonNull
private OperationStatus status;
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java
index 10da162..d2e31f0 100644
--- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Product.java
@@ -21,7 +21,7 @@ public class Product {
private int id;
@Column(nullable = false, name = "type")
- @Enumerated(EnumType.ORDINAL)
+ @Enumerated(EnumType.STRING)
@NonNull
private ProductType type;
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java
index 58fe4d9..7c24e5b 100644
--- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java
@@ -35,7 +35,7 @@ public class ProductSlots {
private long amount;
@Column(nullable = false, name = "status")
- @Enumerated(EnumType.ORDINAL)
+ @Enumerated(EnumType.STRING)
@NonNull
private ProductStorageStatus status;
diff --git a/src/main/sql/1_create-database.down.sql b/src/main/sql/1_create-database.down.sql
index f43aba0..bc28179 100644
--- a/src/main/sql/1_create-database.down.sql
+++ b/src/main/sql/1_create-database.down.sql
@@ -1,12 +1,9 @@
DROP TABLE IF EXISTS operation_products;
DROP TABLE IF EXISTS operations;
-DROP TABLE IF EXISTS operation_statuses;
DROP TYPE IF EXISTS OPERATION_TYPE;
DROP TABLE IF EXISTS product_slots;
-DROP TABLE IF EXISTS product_storage_statues;
DROP TABLE IF EXISTS storage_slots;
DROP TABLE IF EXISTS partner_contacts;
DROP TABLE IF EXISTS partners;
DROP TYPE IF EXISTS PARTNER_TYPE;
-DROP TABLE IF EXISTS products;
-DROP TABLE IF EXISTS product_types; \ No newline at end of file
+DROP TABLE IF EXISTS products; \ No newline at end of file
diff --git a/src/main/sql/1_create-database.up.sql b/src/main/sql/1_create-database.up.sql
index d4566fc..c1a63f4 100644
--- a/src/main/sql/1_create-database.up.sql
+++ b/src/main/sql/1_create-database.up.sql
@@ -1,11 +1,6 @@
-CREATE TABLE product_types(
- id INTEGER PRIMARY KEY,
- name TEXT NOT NULL
-);
-
CREATE TABLE products(
id INTEGER PRIMARY KEY,
- type_id INTEGER NOT NULL REFERENCES product_types(id),
+ type TEXT NOT NULL,
height INTEGER NOT NULL,
width INTEGER NOT NULL,
depth INTEGER NOT NULL,
@@ -40,33 +35,23 @@ CREATE TABLE storage_slots(
depth INTEGER NOT NULL
);
-CREATE TABLE product_storage_statues(
- id INTEGER PRIMARY KEY,
- name TEXT NOT NULL
-);
-
CREATE TABLE product_slots(
id INTEGER PRIMARY KEY,
product_id INTEGER NOT NULL REFERENCES products(id),
slot_id INTEGER NOT NULL REFERENCES storage_slots(id),
amount INTEGER NOT NULL CHECK (amount > 0),
- status_id INTEGER NOT NULL REFERENCES product_storage_statues(id),
+ status TEXT NOT NULL,
placement_time TIMESTAMP NOT NULL
);
CREATE TYPE OPERATION_TYPE AS ENUM('SUPPLY', 'ISSUE');
-CREATE TABLE operation_statues(
- id INTEGER PRIMARY KEY,
- name TEXT NOT NULL
-);
-
CREATE TABLE operations(
id INTEGER PRIMARY KEY,
partner_id INTEGER NOT NULL REFERENCES partners(id),
responsible_id INTEGER NOT NULL REFERENCES partner_contacts(id),
type OPERATION_TYPE NOT NULL,
- status_id INTEGER NOT NULL REFERENCES operation_statues(id),
+ status TEXT NOT NULL,
date_created TIMESTAMP NOT NULL,
date_finished TIMESTAMP NULL
);