diff --git a/doc_db/doc_db.md b/doc_db/doc_db.md index 256bd97..ce6571c 100644 --- a/doc_db/doc_db.md +++ b/doc_db/doc_db.md @@ -16,7 +16,6 @@ |---|---|---| | *🔑 ⬋ | id| integer autoincrement | | *⬈ | category_id| integer | -| *| stock_number| integer | | *🔍 | designation| varchar(255) | | Indexes | | 🔑 primary key | pk_plugin_materiels_equipment || ON id| @@ -24,32 +23,19 @@ | Foreign Keys | | | Fk_plugin_materiels_equipment | ( category_id ) ref plugin_materiels_category (id) | -### Table plugin_materiels_entry +### Table plugin_materiels_movement | Idx | Field Name | Data Type | Description | |---|---|---|---| | *🔑 | id| integer autoincrement | | +| *| side| boolean | 0 -> entry, 1 -> output | | *| kind| varchar(20) | Achat, Don, Récupération, ... | | *| equipment_number| integer | | | *⬈ | equipment_id| integer | | -| *| entry_date| date | | +| *| mvt_date| date | | | | additional_comment| varchar(255) | | | Indexes | | 🔑 primary key | pk_plugin_materiels_entry | | | Foreign Keys | -| | Fk_plugin_materiels_entry | ( equipment_id ) ref plugin_materiels_equipment (id) | | - -### Table plugin_materiels_output -| Idx | Field Name | Data Type | Description | -|---|---|---|---| -| *🔑 | id| integer autoincrement | | -| *| kind| varchar(20) | Vente, Don, Prêt, ... | -| *| equipment_number| integer | | -| *⬈ | equipment_id| integer | | -| *| output_date| date | | -| | additional_comment| varchar(255) | | -| Indexes | -| 🔑 primary key | pk_plugin_materiels_output || ON id | | -| Foreign Keys | -| | Fk_plugin_materiels_output | ( equipment_id ) ref plugin_materiels_equipment (id) | | +| | Fk_plugin_materiels_movement | ( equipment_id ) ref plugin_materiels_equipment (id) | | | * -> NOT NULL diff --git a/doc_db/schema.png b/doc_db/schema.png index 2be8f41..3999e14 100644 Binary files a/doc_db/schema.png and b/doc_db/schema.png differ diff --git a/src/schema.sql b/src/schema.sql index 3b6cb12..ca187f1 100644 --- a/src/schema.sql +++ b/src/schema.sql @@ -12,30 +12,9 @@ CREATE TABLE IF NOT EXISTS plugin_materiels_equipment ( FOREIGN KEY ( category_id ) REFERENCES plugin_materiels_category( id ) ON DELETE RESTRICT ON UPDATE CASCADE ); -CREATE TABLE IF NOT EXISTS plugin_materiels_entry ( - id integer NOT NULL PRIMARY KEY autoincrement, - kind varchar(20) NOT NULL, - equipment_number integer NOT NULL, - equipment_id integer NOT NULL, - entry_date date NOT NULL, - additional_comment varchar(255), - FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE -); - -CREATE TABLE IF NOT EXISTS plugin_materiels_output ( - id integer NOT NULL PRIMARY KEY autoincrement, - kind varchar(20) NOT NULL, - equipment_number integer NOT NULL, - equipment_id integer NOT NULL, - output_date date NOT NULL, - additional_comment varchar(255), - FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE -); - - CREATE TABLE IF NOT EXISTS plugin_materiels_movement ( id integer NOT NULL PRIMARY KEY autoincrement, - side boolean NOT NULL CHECK(side IN(0,1)), /*0 -> entry, 1 -> output*/ + side boolean NOT NULL CHECK(side IN(0,1)), kind varchar(20) NOT NULL, equipment_number integer NOT NULL, equipment_id integer NOT NULL,