/
nalsur
/
winter
Обзор
Документация
Войти
/
nalsur
/
winter
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/main/resources/db/migration/V1__init.sql
63 строки
2 KB
Ruslan Bulatov
Правки по второму уроку
12 окт 2024, 19:51
12 окт 2024, 19:51
7eb1a4f
Код
Авторство
О чём код?
create table products ( id bigserial primary key, title varchar(255), price int, created_at timestamp default current_timestamp, updated_at timestamp default current_timestamp ); insert into products (title, price) values ('Milk', 80), ('Bread', 25), ('Chesese', 300); create table users ( id bigserial primary key, username varchar(36) not null, password varchar(80) not null ); create table orders ( id bigserial primary key, user_id bigint not null references users (id), total_price int not null, address text, phone text, created_at timestamp default current_timestamp, updated_at timestamp default current_timestamp ); create table order_items ( id bigserial primary key, product_id bigint not null references products (id), order_id bigint not null references orders (id), quantity int not null, price_per_product int not null, price int not null, created_at timestamp default current_timestamp, updated_at timestamp default current_timestamp ); create table roles ( id bigserial primary key, name varchar(50) not null ); create table users_roles ( user_id bigint not null references users (id), role_id bigint not null references roles (id), primary key (user_id, role_id) ); insert into users (username, password) values ('bob', '$2a$12$gwoYN7nDUn/oeiyQqaw.SeFUigvEVDLNLXo2EGFrjbq289TUR7pkW'), ('john', '$2a$12$gwoYN7nDUn/oeiyQqaw.SeFUigvEVDLNLXo2EGFrjbq289TUR7pkW'); insert into roles (name) values ('ROLE_USER'), ('ROLE_ADMIN'); insert into users_roles (user_id, role_id) values (1,1), (2,2);