diff options
author | mrfoxygmfr <mrfoxygmfr@sch9.ru> | 2025-03-23 15:15:06 +0300 |
---|---|---|
committer | mrfoxygmfr <mrfoxygmfr@sch9.ru> | 2025-03-23 15:15:06 +0300 |
commit | dd941eb5d594eef99e921151fb9fbb4793757229 (patch) | |
tree | f5723cd2261857288c690543a3d70ad118a72afa | |
parent | 249c81ef4cf1db3cf4248c33fe614ff299e2dd57 (diff) |
fix(db): fix auto increment for ids
8 files changed, 14 insertions, 14 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 1f5b911..51b8bbd 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 @@ -16,7 +16,7 @@ import java.util.Set; @AllArgsConstructor public class Operation { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java index 0842437..837e42e 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java @@ -13,7 +13,7 @@ import lombok.*; @AllArgsConstructor public class OperationProducts { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java index 13d24c0..78f203c 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Partner.java @@ -15,7 +15,7 @@ import java.util.Set; @AllArgsConstructor public class Partner { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java index 2299e8e..e25d178 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java @@ -13,7 +13,7 @@ import lombok.*; @AllArgsConstructor public class PartnerContact { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; 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 3d97271..23c4c6a 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 @@ -16,7 +16,7 @@ import java.time.Duration; @AllArgsConstructor public class Product { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; 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 4065dc8..6ed814f 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 @@ -15,7 +15,7 @@ import java.sql.Timestamp; @AllArgsConstructor public class ProductSlots { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java index 424cab2..74253c0 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/StorageSlot.java @@ -13,7 +13,7 @@ import lombok.*; @AllArgsConstructor public class StorageSlot { @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false, name = "id") private int id; diff --git a/src/main/sql/1_create-database.up.sql b/src/main/sql/1_create-database.up.sql index c9179de..a081e0e 100644 --- a/src/main/sql/1_create-database.up.sql +++ b/src/main/sql/1_create-database.up.sql @@ -1,5 +1,5 @@ CREATE TABLE products( - id INTEGER PRIMARY KEY, + id SERIAL PRIMARY KEY, name TEXT NOT NULL, type TEXT NOT NULL, height INTEGER NOT NULL, @@ -11,7 +11,7 @@ CREATE TABLE products( CREATE TYPE PARTNER_TYPE AS ENUM('SUPPLIER', 'ISSUER'); CREATE TABLE partners( - id INTEGER PRIMARY KEY, + id SERIAL PRIMARY KEY, name TEXT NOT NULL, tax_number TEXT NOT NULL, type PARTNER_TYPE NOT NULL, @@ -19,7 +19,7 @@ CREATE TABLE partners( ); CREATE TABLE partner_contacts( - id INTEGER PRIMARY KEY, + id SERIAL PRIMARY KEY, partner_id INTEGER NOT NULL REFERENCES partners(id), surname TEXT NOT NULL, name TEXT NOT NULL, @@ -29,7 +29,7 @@ CREATE TABLE partner_contacts( ); CREATE TABLE storage_slots( - id INTEGER PRIMARY KEY, + id SERIAL PRIMARY KEY, location TEXT NOT NULL, height INTEGER NOT NULL, width INTEGER NOT NULL, @@ -37,7 +37,7 @@ CREATE TABLE storage_slots( ); CREATE TABLE product_slots( - id INTEGER PRIMARY KEY, + id SERIAL 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), @@ -48,7 +48,7 @@ CREATE TABLE product_slots( CREATE TYPE OPERATION_TYPE AS ENUM('SUPPLY', 'ISSUE'); CREATE TABLE operations( - id INTEGER PRIMARY KEY, + id SERIAL PRIMARY KEY, partner_id INTEGER NOT NULL REFERENCES partners(id), responsible_id INTEGER NOT NULL REFERENCES partner_contacts(id), type OPERATION_TYPE NOT NULL, @@ -58,7 +58,7 @@ CREATE TABLE operations( ); CREATE TABLE operation_products( - id INTEGER PRIMARY KEY, + id SERIAL PRIMARY KEY, operation_id INTEGER NOT NULL REFERENCES operations(id), product_id INTEGER NOT NULL REFERENCES products(id), amount INTEGER NOT NULL CHECK (amount > 0) |