-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·78 lines (72 loc) · 2.1 KB
/
make.sh
File metadata and controls
executable file
·78 lines (72 loc) · 2.1 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Check if a command is provided
if [ -z "$1" ]; then
echo "Usage: ./make.sh <command> [--username=<username>]"
echo "Available commands:"
echo " add_user --username=<username> Add a new user"
echo " init Install uv when needed and run initial migrations to create database"
echo " make_migrations Generate new migrations"
exit 1
fi
COMMAND=$1
shift # Shift the command argument to process the rest
case $COMMAND in
add_user)
# Parse the --username argument
for arg in "$@"; do
case $arg in
--username=*)
USERNAME="${arg#*=}"
;;
*)
echo "Invalid argument: $arg"
exit 1
;;
esac
done
if [ -z "$USERNAME" ]; then
echo "Usage: ./make.sh add_user --username=<username>"
exit 1
fi
# Call the Python function
uv run python -c "from src.UI.Console.Component.User.add_user import add_user; add_user('$USERNAME')"
;;
init)
# Install uv if not already installed
if ! command -v uv &> /dev/null; then
echo "uv is not installed. Installing uv..."
curl -LsSf https://astral.sh/uv/0.5.2/install.sh | sh
if [ $? -ne 0 ]; then
echo "Failed to install uv. Please check your environment and try again."
exit 1
fi
echo "uv installed successfully."
else
echo "uv is already installed."
fi
# Run migrations to initialize the database
echo "Running initial migrations..."
uv run python manage.py migrate
if [ $? -eq 0 ]; then
echo "Database initialized successfully."
else
echo "Failed to run migrations. Please check the error above."
exit 1
fi
;;
make_migrations)
# Create new migrations after adding an entity
echo "Making migrations..."
uv run python manage.py makemigrations
if [ $? -eq 0 ]; then
echo "Migrations generated successfully."
else
echo "Failed to generate migrations. Please check the error above."
exit 1
fi
;;
*)
echo "Unknown command: $COMMAND"
exit 1
;;
esac