Добавил базу данных для курсовой
This commit is contained in:
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("PokemonAPI")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("PokemonAPI")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+fcec977971f8728ba933fadaff24f0161236fcb9")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2b1f86a4a5b4e4c225a49bcf2ae842743e512631")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("PokemonAPI")]
|
[assembly: System.Reflection.AssemblyProductAttribute("PokemonAPI")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("PokemonAPI")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("PokemonAPI")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
b03b70b96e98e26f8a396ab511f546030999e29f489f4f2c1c20ff3a2ea4df55
|
9826baa51788e5df7c79576727d1fd1602a2816bcb4b34ce865d6f4f57d0a5d2
|
||||||
|
|||||||
+2
-2
@@ -12,13 +12,13 @@ build_property.EntryPointFilePath =
|
|||||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
build_property.RootNamespace = PokemonAPI
|
build_property.RootNamespace = PokemonAPI
|
||||||
build_property.RootNamespace = PokemonAPI
|
build_property.RootNamespace = PokemonAPI
|
||||||
build_property.ProjectDir = Z:\чето\prog-radzh\works\Api\lab-01\PokemonAPI\PokemonAPI\
|
build_property.ProjectDir = Z:\чето\Prog-Samoilov\works\Api\lab-01\PokemonAPI\PokemonAPI\
|
||||||
build_property.EnableComHosting =
|
build_property.EnableComHosting =
|
||||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||||
build_property.RazorLangVersion = 10.0
|
build_property.RazorLangVersion = 10.0
|
||||||
build_property.SupportLocalizedComponentNames =
|
build_property.SupportLocalizedComponentNames =
|
||||||
build_property.GenerateRazorMetadataSourceChecksumAttributes =
|
build_property.GenerateRazorMetadataSourceChecksumAttributes =
|
||||||
build_property.MSBuildProjectDirectory = Z:\чето\prog-radzh\works\Api\lab-01\PokemonAPI\PokemonAPI
|
build_property.MSBuildProjectDirectory = Z:\чето\Prog-Samoilov\works\Api\lab-01\PokemonAPI\PokemonAPI
|
||||||
build_property._RazorSourceGeneratorDebug =
|
build_property._RazorSourceGeneratorDebug =
|
||||||
build_property.EffectiveAnalysisLevelStyle = 10.0
|
build_property.EffectiveAnalysisLevelStyle = 10.0
|
||||||
build_property.EnableCodeStyleSeverity =
|
build_property.EnableCodeStyleSeverity =
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
17920641775969382
|
17955951351930851
|
||||||
Generated
+15
@@ -0,0 +1,15 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Rider ignored files
|
||||||
|
/modules.xml
|
||||||
|
/contentModel.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/.idea.lab-01.iml
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
Generated
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+15
@@ -0,0 +1,15 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Rider ignored files
|
||||||
|
/modules.xml
|
||||||
|
/contentModel.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/.idea.lab-02.iml
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
Generated
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+15
@@ -0,0 +1,15 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Rider ignored files
|
||||||
|
/modules.xml
|
||||||
|
/contentModel.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/.idea.lab-03.iml
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
Generated
+4
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -87,4 +87,8 @@ fun main() {
|
|||||||
println("Множитель урона: x$weaknessMultiplier")
|
println("Множитель урона: x$weaknessMultiplier")
|
||||||
println("Категория здоровья: $healthState")
|
println("Категория здоровья: $healthState")
|
||||||
println("========================================")
|
println("========================================")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val healState: String = when {
|
||||||
|
hpPercent == 0 -> "Нкаут"
|
||||||
|
|
||||||
@@ -0,0 +1,313 @@
|
|||||||
|
-- DROP SCHEMA public;
|
||||||
|
|
||||||
|
CREATE SCHEMA public AUTHORIZATION pg_database_owner;
|
||||||
|
|
||||||
|
-- DROP SEQUENCE public.addresses_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.addresses_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.categories_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.categories_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.couriers_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.couriers_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.menu_items_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.menu_items_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.order_items_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.order_items_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.orders_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.orders_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.payments_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.payments_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.restaurants_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.restaurants_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;
|
||||||
|
-- DROP SEQUENCE public.users_id_seq;
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.users_id_seq
|
||||||
|
INCREMENT BY 1
|
||||||
|
MINVALUE 1
|
||||||
|
MAXVALUE 9223372036854775807
|
||||||
|
START 1
|
||||||
|
CACHE 1
|
||||||
|
NO CYCLE;-- public.categories определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.categories;
|
||||||
|
|
||||||
|
CREATE TABLE public.categories (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"name" varchar(100) NOT NULL,
|
||||||
|
CONSTRAINT categories_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT categories_name_key UNIQUE (name),
|
||||||
|
CONSTRAINT categories_name_not_null NOT NULL name,
|
||||||
|
CONSTRAINT categories_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.restaurants определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.restaurants;
|
||||||
|
|
||||||
|
CREATE TABLE public.restaurants (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
"name" varchar(150) NOT NULL,
|
||||||
|
address varchar(255) NOT NULL,
|
||||||
|
min_order_amount numeric(10, 2) DEFAULT 0 NOT NULL,
|
||||||
|
delivery_fee numeric(10, 2) DEFAULT 0 NOT NULL,
|
||||||
|
is_open bool DEFAULT true NOT NULL,
|
||||||
|
CONSTRAINT restaurants_address_not_null NOT NULL address,
|
||||||
|
CONSTRAINT restaurants_delivery_fee_check CHECK ((delivery_fee >= (0)::numeric)),
|
||||||
|
CONSTRAINT restaurants_delivery_fee_not_null NOT NULL delivery_fee,
|
||||||
|
CONSTRAINT restaurants_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT restaurants_is_open_not_null NOT NULL is_open,
|
||||||
|
CONSTRAINT restaurants_min_order_amount_check CHECK ((min_order_amount >= (0)::numeric)),
|
||||||
|
CONSTRAINT restaurants_min_order_amount_not_null NOT NULL min_order_amount,
|
||||||
|
CONSTRAINT restaurants_name_not_null NOT NULL name,
|
||||||
|
CONSTRAINT restaurants_pkey PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.users определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.users;
|
||||||
|
|
||||||
|
CREATE TABLE public.users (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
full_name varchar(150) NOT NULL,
|
||||||
|
email varchar(255) NOT NULL,
|
||||||
|
phone varchar(30) NOT NULL,
|
||||||
|
"role" varchar(20) NOT NULL,
|
||||||
|
created_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
CONSTRAINT users_created_at_not_null NOT NULL created_at,
|
||||||
|
CONSTRAINT users_email_key UNIQUE (email),
|
||||||
|
CONSTRAINT users_email_not_null NOT NULL email,
|
||||||
|
CONSTRAINT users_full_name_not_null NOT NULL full_name,
|
||||||
|
CONSTRAINT users_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT users_phone_key UNIQUE (phone),
|
||||||
|
CONSTRAINT users_phone_not_null NOT NULL phone,
|
||||||
|
CONSTRAINT users_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT users_role_check CHECK (((role)::text = ANY ((ARRAY['customer'::character varying, 'courier'::character varying, 'manager'::character varying, 'admin'::character varying])::text[]))),
|
||||||
|
CONSTRAINT users_role_not_null NOT NULL role
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.addresses определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.addresses;
|
||||||
|
|
||||||
|
CREATE TABLE public.addresses (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
user_id int8 NOT NULL,
|
||||||
|
city varchar(100) NOT NULL,
|
||||||
|
street varchar(150) NOT NULL,
|
||||||
|
building varchar(30) NOT NULL,
|
||||||
|
apartment varchar(30) NULL,
|
||||||
|
"comment" text NULL,
|
||||||
|
CONSTRAINT addresses_building_not_null NOT NULL building,
|
||||||
|
CONSTRAINT addresses_city_not_null NOT NULL city,
|
||||||
|
CONSTRAINT addresses_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT addresses_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT addresses_street_not_null NOT NULL street,
|
||||||
|
CONSTRAINT addresses_user_id_not_null NOT NULL user_id,
|
||||||
|
CONSTRAINT addresses_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.couriers определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.couriers;
|
||||||
|
|
||||||
|
CREATE TABLE public.couriers (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
user_id int8 NOT NULL,
|
||||||
|
vehicle_type varchar(30) NOT NULL,
|
||||||
|
status varchar(20) DEFAULT 'offline'::character varying NOT NULL,
|
||||||
|
CONSTRAINT couriers_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT couriers_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT couriers_status_check CHECK (((status)::text = ANY ((ARRAY['available'::character varying, 'delivering'::character varying, 'offline'::character varying])::text[]))),
|
||||||
|
CONSTRAINT couriers_status_not_null NOT NULL status,
|
||||||
|
CONSTRAINT couriers_user_id_key UNIQUE (user_id),
|
||||||
|
CONSTRAINT couriers_user_id_not_null NOT NULL user_id,
|
||||||
|
CONSTRAINT couriers_vehicle_type_check CHECK (((vehicle_type)::text = ANY ((ARRAY['foot'::character varying, 'bicycle'::character varying, 'scooter'::character varying, 'car'::character varying])::text[]))),
|
||||||
|
CONSTRAINT couriers_vehicle_type_not_null NOT NULL vehicle_type,
|
||||||
|
CONSTRAINT couriers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.menu_items определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.menu_items;
|
||||||
|
|
||||||
|
CREATE TABLE public.menu_items (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
restaurant_id int8 NOT NULL,
|
||||||
|
category_id int8 NOT NULL,
|
||||||
|
"name" varchar(150) NOT NULL,
|
||||||
|
description text NULL,
|
||||||
|
price numeric(10, 2) NOT NULL,
|
||||||
|
is_available bool DEFAULT true NOT NULL,
|
||||||
|
CONSTRAINT menu_items_category_id_not_null NOT NULL category_id,
|
||||||
|
CONSTRAINT menu_items_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT menu_items_is_available_not_null NOT NULL is_available,
|
||||||
|
CONSTRAINT menu_items_name_not_null NOT NULL name,
|
||||||
|
CONSTRAINT menu_items_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT menu_items_price_check CHECK ((price > (0)::numeric)),
|
||||||
|
CONSTRAINT menu_items_price_not_null NOT NULL price,
|
||||||
|
CONSTRAINT menu_items_restaurant_id_not_null NOT NULL restaurant_id,
|
||||||
|
CONSTRAINT menu_items_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.categories(id),
|
||||||
|
CONSTRAINT menu_items_restaurant_id_fkey FOREIGN KEY (restaurant_id) REFERENCES public.restaurants(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.orders определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.orders;
|
||||||
|
|
||||||
|
CREATE TABLE public.orders (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
customer_id int8 NOT NULL,
|
||||||
|
restaurant_id int8 NOT NULL,
|
||||||
|
address_id int8 NOT NULL,
|
||||||
|
courier_id int8 NULL,
|
||||||
|
status varchar(20) DEFAULT 'created'::character varying NOT NULL,
|
||||||
|
items_total numeric(10, 2) NOT NULL,
|
||||||
|
delivery_fee numeric(10, 2) NOT NULL,
|
||||||
|
total_amount numeric(10, 2) NOT NULL,
|
||||||
|
created_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
|
CONSTRAINT orders_address_id_not_null NOT NULL address_id,
|
||||||
|
CONSTRAINT orders_created_at_not_null NOT NULL created_at,
|
||||||
|
CONSTRAINT orders_customer_id_not_null NOT NULL customer_id,
|
||||||
|
CONSTRAINT orders_delivery_fee_check CHECK ((delivery_fee >= (0)::numeric)),
|
||||||
|
CONSTRAINT orders_delivery_fee_not_null NOT NULL delivery_fee,
|
||||||
|
CONSTRAINT orders_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT orders_items_total_check CHECK ((items_total >= (0)::numeric)),
|
||||||
|
CONSTRAINT orders_items_total_not_null NOT NULL items_total,
|
||||||
|
CONSTRAINT orders_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT orders_restaurant_id_not_null NOT NULL restaurant_id,
|
||||||
|
CONSTRAINT orders_status_check CHECK (((status)::text = ANY ((ARRAY['created'::character varying, 'confirmed'::character varying, 'cooking'::character varying, 'delivering'::character varying, 'delivered'::character varying, 'cancelled'::character varying])::text[]))),
|
||||||
|
CONSTRAINT orders_status_not_null NOT NULL status,
|
||||||
|
CONSTRAINT orders_total_amount_check CHECK ((total_amount >= (0)::numeric)),
|
||||||
|
CONSTRAINT orders_total_amount_not_null NOT NULL total_amount,
|
||||||
|
CONSTRAINT orders_address_id_fkey FOREIGN KEY (address_id) REFERENCES public.addresses(id),
|
||||||
|
CONSTRAINT orders_courier_id_fkey FOREIGN KEY (courier_id) REFERENCES public.couriers(id),
|
||||||
|
CONSTRAINT orders_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES public.users(id),
|
||||||
|
CONSTRAINT orders_restaurant_id_fkey FOREIGN KEY (restaurant_id) REFERENCES public.restaurants(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.payments определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.payments;
|
||||||
|
|
||||||
|
CREATE TABLE public.payments (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
order_id int8 NOT NULL,
|
||||||
|
"method" varchar(20) NOT NULL,
|
||||||
|
status varchar(20) DEFAULT 'pending'::character varying NOT NULL,
|
||||||
|
amount numeric(10, 2) NOT NULL,
|
||||||
|
paid_at timestamp NULL,
|
||||||
|
CONSTRAINT payments_amount_check CHECK ((amount >= (0)::numeric)),
|
||||||
|
CONSTRAINT payments_amount_not_null NOT NULL amount,
|
||||||
|
CONSTRAINT payments_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT payments_method_check CHECK (((method)::text = ANY ((ARRAY['card'::character varying, 'cash'::character varying, 'online'::character varying])::text[]))),
|
||||||
|
CONSTRAINT payments_method_not_null NOT NULL method,
|
||||||
|
CONSTRAINT payments_order_id_not_null NOT NULL order_id,
|
||||||
|
CONSTRAINT payments_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT payments_status_check CHECK (((status)::text = ANY ((ARRAY['pending'::character varying, 'paid'::character varying, 'refunded'::character varying])::text[]))),
|
||||||
|
CONSTRAINT payments_status_not_null NOT NULL status,
|
||||||
|
CONSTRAINT payments_order_id_fkey FOREIGN KEY (order_id) REFERENCES public.orders(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
-- public.order_items определение
|
||||||
|
|
||||||
|
-- Drop table
|
||||||
|
|
||||||
|
-- DROP TABLE public.order_items;
|
||||||
|
|
||||||
|
CREATE TABLE public.order_items (
|
||||||
|
id bigserial NOT NULL,
|
||||||
|
order_id int8 NOT NULL,
|
||||||
|
menu_item_id int8 NOT NULL,
|
||||||
|
quantity int4 NOT NULL,
|
||||||
|
unit_price numeric(10, 2) NOT NULL,
|
||||||
|
CONSTRAINT order_items_id_not_null NOT NULL id,
|
||||||
|
CONSTRAINT order_items_menu_item_id_not_null NOT NULL menu_item_id,
|
||||||
|
CONSTRAINT order_items_order_id_menu_item_id_key UNIQUE (order_id, menu_item_id),
|
||||||
|
CONSTRAINT order_items_order_id_not_null NOT NULL order_id,
|
||||||
|
CONSTRAINT order_items_pkey PRIMARY KEY (id),
|
||||||
|
CONSTRAINT order_items_quantity_check CHECK ((quantity > 0)),
|
||||||
|
CONSTRAINT order_items_quantity_not_null NOT NULL quantity,
|
||||||
|
CONSTRAINT order_items_unit_price_check CHECK ((unit_price > (0)::numeric)),
|
||||||
|
CONSTRAINT order_items_unit_price_not_null NOT NULL unit_price,
|
||||||
|
CONSTRAINT order_items_menu_item_id_fkey FOREIGN KEY (menu_item_id) REFERENCES public.menu_items(id),
|
||||||
|
CONSTRAINT order_items_order_id_fkey FOREIGN KEY (order_id) REFERENCES public.orders(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user