venv: using python
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtor if using python3
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txtSetup Database:
sqlalchemy.url = postgresql://dbusername:dbpassword@localhost:5432/yourdatabase or sqlalchemy.url = mysql+pymysql://dbusername:dbpassword@localhost:3306/yourdatabase
Migrate:
alembic revision --autogenerate -m "name_your_table"if there are changes in the SQLAlchemy model (e.g. adding new columns, changing data types, or adding tables), you need to perform a new migration and run the upgrade.
alembic revision --autogenerate -m "add column phone into users"This will create a new migration file in migrations/versions/ with the format migrations/versions/xxxxxxxxxxxx_add_phone_column.py
alembic upgrade headalembic command:
alembic init migrationsalembic historyalembic history --verbosealembic currentalembic headsalembic downgrade -1or by id
alembic downgrade <commit_id>alembic headsCompile :
uvicorn src.main:app --reload└── 📁migrations
└── 📁versions
└── 951cd5d7639e_initial_migration.py
└── abb10ccaa8b5_add_tokenblacklist_table.py
└── cc893fd61fb5_add_expires_at_to_token_blacklist.py
└── e4eb2e45db20_initial_migration.py
└── env.py
└── README
└── script.py.make
└── 📁src
└── 📁app
└── 📁v1
└── api.py
└── 📁endpoints
└── auth.py
└── category.py
└── radiograph.py
└── 📁core
└── config.py
└── security.py
└── 📁db
└── base.py
└── session.py
└── 📁handlers
└── response_handler.py
└── 📁ml_models
└── unet_gigi_100.h5
└── unet_gigi_penyakit.h5
└── 📁models
└── category_model.py
└── radiograph_model.py
└── token_blacklist_model.py
└── user_model.py
└── 📁schemas
└── category_schema.py
└── radiograph_schema.py
└── user_schema.py
└── 📁seeds
└── category_seeder.py
└── run_seeder.py
└── user_seeder.py
└── 📁services
└── radiograph_service.py
└── 📁utils
└── dependencies.py
└── .DS_Store
└── main.py