-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (32 loc) · 1.19 KB
/
Makefile
File metadata and controls
40 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
.PHONY: migration-add migration-remove migration-update migration-apply migration-remove-last db-up db-down
# Project paths
INFRASTRUCTURE_PROJECT = Slouch.Infrastructure
API_PROJECT = Slouch.API
# Add a new migration
# Usage: make migration-add NAME=MigrationName
migration-add:
@if [ -z "$(NAME)" ]; then \
echo "Error: Migration name is required. Usage: make migration-add NAME=YourMigrationName"; \
exit 1; \
fi
dotnet ef migrations add $(NAME) --project $(INFRASTRUCTURE_PROJECT) --startup-project $(API_PROJECT)
# Remove the last migration
migration-remove-last:
dotnet ef migrations remove --project $(INFRASTRUCTURE_PROJECT) --startup-project $(API_PROJECT)
# Update the database with pending migrations
migration-apply:
dotnet ef database update --project $(INFRASTRUCTURE_PROJECT) --startup-project $(API_PROJECT)
# Drop the database
db-drop:
dotnet ef database drop --project $(INFRASTRUCTURE_PROJECT) --startup-project $(API_PROJECT) --force
# Start PostgreSQL container
db-up:
docker-compose up -d
# Stop PostgreSQL container
db-down:
docker-compose down
# Start database and apply migrations
db-reset: db-up
@echo "Waiting for database to be ready..."
@sleep 3
$(MAKE) migration-apply