start backend
This commit is contained in:
@@ -1 +0,0 @@
|
||||
spring.application.name=ReFound
|
||||
36
src/main/resources/application.yaml
Normal file
36
src/main/resources/application.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 5MB
|
||||
max-request-size: 10MB
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/nahodka
|
||||
username: user
|
||||
password: pass
|
||||
driver-class-name: org.postgresql.Driver
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update # на старте удобно
|
||||
show-sql: true
|
||||
properties:
|
||||
hibernate:
|
||||
format_sql: true
|
||||
|
||||
data:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
|
||||
cache:
|
||||
type: redis
|
||||
|
||||
liquibase:
|
||||
change-log: classpath:db/changelog/db.changelog-master.yaml
|
||||
|
||||
file:
|
||||
upload-dir: uploads/
|
||||
|
||||
cache:
|
||||
ttl: 300
|
||||
57
src/main/resources/db/changelog/001-init.yaml
Normal file
57
src/main/resources/db/changelog/001-init.yaml
Normal file
@@ -0,0 +1,57 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 001-create-users
|
||||
author: you
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: users
|
||||
columns:
|
||||
- column: { name: id, type: BIGSERIAL, constraints: { primaryKey: true } }
|
||||
- column: { name: email, type: VARCHAR(255), constraints: { nullable: false, unique: true } }
|
||||
- column: { name: password, type: VARCHAR(255), constraints: { nullable: false } }
|
||||
- column: { name: created_at, type: TIMESTAMP }
|
||||
|
||||
- changeSet:
|
||||
id: 002-create-posts
|
||||
author: you
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: posts
|
||||
columns:
|
||||
- column: { name: id, type: BIGSERIAL, constraints: { primaryKey: true } }
|
||||
- column: { name: type, type: VARCHAR(20) }
|
||||
- column: { name: title, type: VARCHAR(255) }
|
||||
- column: { name: description, type: TEXT }
|
||||
- column: { name: category, type: VARCHAR(100) }
|
||||
- column: { name: city, type: VARCHAR(100) }
|
||||
- column: { name: district, type: VARCHAR(100) }
|
||||
- column: { name: latitude, type: DOUBLE }
|
||||
- column: { name: longitude, type: DOUBLE }
|
||||
- column: { name: status, type: VARCHAR(20) }
|
||||
- column: { name: created_at, type: TIMESTAMP }
|
||||
- column: { name: user_id, type: BIGINT }
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: posts
|
||||
baseColumnNames: user_id
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
constraintName: fk_posts_user # ✅ ДОБАВИТЬ
|
||||
|
||||
- changeSet:
|
||||
id: 003-create-images
|
||||
author: you
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: images
|
||||
columns:
|
||||
- column: { name: id, type: BIGSERIAL, constraints: { primaryKey: true } }
|
||||
- column: { name: url, type: VARCHAR(500) }
|
||||
- column: { name: post_id, type: BIGINT }
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: images
|
||||
baseColumnNames: post_id
|
||||
referencedTableName: posts
|
||||
referencedColumnNames: id
|
||||
constraintName: fk_images_post # ✅
|
||||
37
src/main/resources/db/changelog/002-message.yaml
Normal file
37
src/main/resources/db/changelog/002-message.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 004-create-messages
|
||||
author: you
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: messages
|
||||
columns:
|
||||
- column: { name: id, type: BIGSERIAL, constraints: { primaryKey: true } }
|
||||
- column: { name: sender_id, type: BIGINT }
|
||||
- column: { name: receiver_id, type: BIGINT }
|
||||
- column: { name: content, type: TEXT }
|
||||
- column: { name: created_at, type: TIMESTAMP }
|
||||
- column: { name: is_read, type: BOOLEAN }
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: messages
|
||||
baseColumnNames: sender_id
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
constraintName: fk_messages_sender # ✅
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: messages
|
||||
baseColumnNames: receiver_id
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
constraintName: fk_messages_receiver # ✅
|
||||
|
||||
# 🔥 индекс для чата
|
||||
- createIndex:
|
||||
tableName: messages
|
||||
indexName: idx_messages_users
|
||||
columns:
|
||||
- column: { name: sender_id }
|
||||
- column: { name: receiver_id }
|
||||
- column: { name: created_at }
|
||||
31
src/main/resources/db/changelog/003-favorite.yaml
Normal file
31
src/main/resources/db/changelog/003-favorite.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: 005-create-favorites
|
||||
author: you
|
||||
changes:
|
||||
- createTable:
|
||||
tableName: favorites
|
||||
columns:
|
||||
- column: { name: id, type: BIGSERIAL, constraints: { primaryKey: true } }
|
||||
- column: { name: user_id, type: BIGINT }
|
||||
- column: { name: post_id, type: BIGINT }
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: favorites
|
||||
baseColumnNames: user_id
|
||||
referencedTableName: users
|
||||
referencedColumnNames: id
|
||||
constraintName: fk_favorites_user # ✅
|
||||
|
||||
- addForeignKeyConstraint:
|
||||
baseTableName: favorites
|
||||
baseColumnNames: post_id
|
||||
referencedTableName: posts
|
||||
referencedColumnNames: id
|
||||
constraintName: fk_favorites_post # ✅
|
||||
|
||||
# 🔥 защита от дублей
|
||||
- addUniqueConstraint:
|
||||
tableName: favorites
|
||||
columnNames: user_id, post_id
|
||||
constraintName: unique_user_post
|
||||
9
src/main/resources/db/changelog/db.changelog-master.yaml
Normal file
9
src/main/resources/db/changelog/db.changelog-master.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
databaseChangeLog:
|
||||
- include:
|
||||
file: db/changelog/001-init.yaml
|
||||
|
||||
- include:
|
||||
file: db/changelog/002-message.yaml
|
||||
|
||||
- include:
|
||||
file: db/changelog/003-favorite.yaml
|
||||
Reference in New Issue
Block a user