You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
├── main.py # Main entry point for running the app
64
+
├── alembic.ini # Alembic configuration file
65
+
├── Makefile # Makefile for common commands
57
66
├── requirements.txt # Python dependencies
58
67
├── setup.py # Setup script
59
68
├── deploy_to_toolforge.sh # Deployment script
@@ -117,7 +126,21 @@ backend/
117
126
118
127
## Running the Application
119
128
120
-
### Development Mode
129
+
### Using Makefile (Recommended)
130
+
131
+
The Makefile provides convenient commands for common tasks:
132
+
133
+
```bash
134
+
# Run the development server
135
+
make run
136
+
# or
137
+
make dev
138
+
139
+
# View all available commands
140
+
make help
141
+
```
142
+
143
+
### Manual Running
121
144
122
145
1.**Start the Flask development server:**
123
146
```bash
@@ -247,6 +270,14 @@ Located in `app/middleware/auth.py`:
247
270
## Development
248
271
249
272
### Running Tests
273
+
274
+
**Using Makefile:**
275
+
```bash
276
+
make test# Run tests
277
+
make test-coverage # Run tests with coverage report
278
+
```
279
+
280
+
**Direct pytest commands:**
250
281
```bash
251
282
# Install test dependencies
252
283
pip install pytest pytest-flask
@@ -260,14 +291,58 @@ The code follows Python PEP 8 standards with comprehensive comments and document
260
291
261
292
### Database Migrations
262
293
263
-
The application includes custom migration scripts in the `migrations/` directory. Migrations are automatically run on application startup, or can be run manually:
294
+
The application uses **Alembic** for database migrations, which provides robust database schema versioning and management.
295
+
296
+
#### Using Alembic
297
+
298
+
```bash
299
+
# Create a new migration (after modifying models)
300
+
alembic revision --autogenerate -m "Description of changes"
301
+
302
+
# Apply migrations
303
+
alembic upgrade head
304
+
305
+
# Rollback to previous version
306
+
alembic downgrade -1
307
+
308
+
# View current migration status
309
+
alembic current
310
+
311
+
# View migration history
312
+
alembic history
313
+
```
314
+
315
+
#### How Alembic Works
316
+
317
+
1.**Migration Files**: Python files in `alembic/versions/` define schema changes
318
+
2.**Version Tracking**: `alembic_version` table in database stores current version
319
+
3.**Migration Chain**: Each migration points to the previous one (linked list structure)
320
+
4.**Upgrade/Downgrade**: Each migration has functions to apply and reverse changes
321
+
322
+
#### Typical Workflow
323
+
324
+
1. Modify your models in `app/models/`
325
+
2. Generate migration: `make migrate-create MSG="Add new field"`
326
+
3. Review the generated file in `alembic/versions/`
0 commit comments