You've already forked reloading-manager
No changes made
This commit is contained in:
2
backend/migrations/000001_create_initial_tables.down.sql
Normal file
2
backend/migrations/000001_create_initial_tables.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
drop table if exists bullets;
|
||||
drop table if exists manufacturers;
|
||||
42
backend/migrations/000001_create_initial_tables.up.sql
Normal file
42
backend/migrations/000001_create_initial_tables.up.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
create table manufacturers
|
||||
(
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
name varchar(255) not null,
|
||||
url varchar(255),
|
||||
created_at timestamp default NOW() not null
|
||||
);
|
||||
|
||||
insert into manufacturers (name, url)
|
||||
values ('Hornady', 'https://www.hornady.com/'),
|
||||
('CCI', 'https://www.cci-ammunition.com/'),
|
||||
('IMR Powders', 'https://shop.hodgdon.com/imr/'),
|
||||
('Accurate Powders', 'https://hodgdonpowderco.com/accurate/'),
|
||||
('Federal', 'https://www.federalpremium.com/'),
|
||||
('Remington', 'https://www.remington.com/'),
|
||||
('Winchester', 'https://www.winchester.com/'),
|
||||
('Speer', 'https://www.speer.com/'),
|
||||
('Nosler', 'https://www.nosler.com/'),
|
||||
('Sierra', 'https://www.sierrabullets.com/'),
|
||||
('Barnes', 'https://www.barnesbullets.com/'),
|
||||
('Berger', 'https://www.bergerbullets.com/'),
|
||||
('Lapua', 'https://www.lapua.com/'),
|
||||
('Norma', 'https://www.norma-ammunition.com/'),
|
||||
('Berrys Bullets', 'https://www.berrysmfg.com/'),
|
||||
('Starline Brass', 'https://www.starlinebrass.com/'),
|
||||
('Swift', 'https://www.swiftbullets.com/');
|
||||
|
||||
create table bullets
|
||||
(
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
name varchar(255) not null,
|
||||
weight int not null,
|
||||
diameter int not null,
|
||||
meta json,
|
||||
photo bytea,
|
||||
manufacturer_id uuid not null,
|
||||
created_at timestamp default NOW() not null
|
||||
);
|
||||
|
||||
alter table bullets
|
||||
add constraint bullets_manufacturers_id_fk
|
||||
foreign key (manufacturer_id) references manufacturers (id);
|
||||
1
backend/migrations/000002_create_powder_tables.down.sql
Normal file
1
backend/migrations/000002_create_powder_tables.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
drop table if exists powders;
|
||||
11
backend/migrations/000002_create_powder_tables.up.sql
Normal file
11
backend/migrations/000002_create_powder_tables.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
create table powders
|
||||
(
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
name varchar(255) not null,
|
||||
meta json,
|
||||
photo bytea,
|
||||
manufacturer_id uuid not null,
|
||||
created_at timestamp default NOW() not null,
|
||||
constraint powders_manufacturers_id_fk
|
||||
foreign key (manufacturer_id) references manufacturers (id)
|
||||
);
|
||||
11
backend/migrations/000003_create_primers_table.up.sql
Normal file
11
backend/migrations/000003_create_primers_table.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
create table primers
|
||||
(
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
name varchar(255) not null,
|
||||
meta json,
|
||||
photo bytea,
|
||||
manufacturer_id uuid not null,
|
||||
created_at timestamp default NOW() not null,
|
||||
constraint primers_manufacturers_id_fk
|
||||
foreign key (manufacturer_id) references manufacturers (id)
|
||||
);
|
||||
2
backend/migrations/000004_create_loads_tables.down.sql
Normal file
2
backend/migrations/000004_create_loads_tables.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
drop table if exists loads;
|
||||
drop table if exists cartridges;
|
||||
32
backend/migrations/000004_create_loads_tables.up.sql
Normal file
32
backend/migrations/000004_create_loads_tables.up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
create table cartridges
|
||||
(
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
name varchar(255) not null,
|
||||
created_at timestamp default current_timestamp not null,
|
||||
meta json not null,
|
||||
constraint cartridges_name_uindex
|
||||
unique (name)
|
||||
);
|
||||
|
||||
create table loads
|
||||
(
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
cartridge_id uuid not null,
|
||||
col float4 not null,
|
||||
powder_id uuid not null,
|
||||
powder_gr float4 not null,
|
||||
primer_id uuid not null,
|
||||
bullet_id uuid not null,
|
||||
photo bytea not null,
|
||||
created_at timestamp default current_timestamp not null,
|
||||
meta json not null,
|
||||
constraint loads_bullets_id_fk
|
||||
foreign key (bullet_id) references bullets (id),
|
||||
constraint loads_powders_id_fk
|
||||
foreign key (powder_id) references powders (id),
|
||||
constraint loads_primers_id_fk
|
||||
foreign key (primer_id) references primers (id),
|
||||
constraint loads_cartridges_id_fk
|
||||
foreign key (cartridge_id) references cartridges (id)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user