stock/stock.sql

113 lines
6.7 KiB
SQL

\c postgres;
drop database tetalab_stock;
create database tetalab_stock;
\c tetalab_stock;
CREATE TABLE stock_users (
id serial primary key,
mail text not NULL,
password text not NULL,
name text not NULL
);
CREATE TABLE stock_kits (
id serial primary key,
name text not NULL,
description text not NULL
);
CREATE TABLE stock_providers (
id serial primary key,
name text not NULL,
address text not NULL,
mail text not NULL,
url text not NULL,
comment text not NULL
);
CREATE TABLE stock_componants (
id serial primary key,
reference varchar(20) unique not NULL,
designation varchar(50) not NULL,
last_price NUMERIC not NULL default 0,
mean_price NUMERIC not NULL default 0,
quantity NUMERIC not NULL default 0,
min_quantity NUMERIC not NULL default 0,
place varchar(15) not NULL,
provider_id integer REFERENCES stock_providers(id)
);
CREATE TABLE stock_kit_compositions (
id serial primary key,
kit_id integer REFERENCES Stock_kits(id),
componant_id integer REFERENCES stock_componants(id),
quantity integer not NULL
);
alter table stock_users owner to tetalab_user;
alter table stock_kits owner to tetalab_user;
alter table stock_providers owner to tetalab_user;
alter table stock_componants owner to tetalab_user;
alter table stock_kit_compositions owner to tetalab_user;
alter database tetalab_stock owner to tetalab_user;
insert into stock_providers (name, address, mail, url, comment)
values ('Tous', 'N/A', 'N/A', 'N/A', 'N/A');
insert into stock_providers (name, address, mail, url, comment)
values ('Aucun', 'N/A', 'N/A', 'N/A', 'N/A');
insert into stock_providers (name, address, mail, url, comment)
values ('China Elec Co', 'Beijing', 'sales@chinaelecco.cc', 'https://chinaelecco', 'Pas cher, mais...');
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-01', 'Resistance 10KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Lor-01', '1 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-02', 'Resistance 11KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-03', 'Resistance 12KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-04', 'Resistance 13KΩ', 13.34, 12.42, 73, 0, 'B 43', 2);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-05', 'Resistance 14KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Lor-02', '2 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-06', 'Resistance 15KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-07', 'Resistance 16KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-08', 'Resistance 17KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-09', 'Resistance 18KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Lor-03', '3 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-10', 'Resistance 19KΩ', 13.34, 12.42, 73, 0, 'B 43', 2);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-11', 'Resistance 20KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-12', 'Resistance 21KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-13', 'Resistance 22KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Lor-04', '4 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-14', 'Resistance 23KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-15', 'Resistance 24KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-16', 'Resistance 25KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-17', 'Resistance 26KΩ', 13.34, 12.42, 73, 0, 'B 43', 2);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Lor-05', '5 Lorem ipsum dolor sit ametconsectetur adipiscing', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-18', 'Resistance 27KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-19', 'Resistance 28KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);
insert into stock_componants (reference, designation, last_price, mean_price, quantity, min_quantity, place, provider_id)
values ('Res-20', 'Resistance 29KΩ', 13.34, 12.42, 73, 0, 'B 43', 3);