UCSD Oasis platform
./dev-setup
to build the project
master
!docker-compose up
- navigate to http://localhost:3000 to see it! 🚀
http://localhost:8000/api/{endpoint-name-here}
If you need to add packages to the frontend app, make sure to do so with yarn and within the docker environment:
docker-compose run --rm ui yarn add PACKAGE_NAME_HERE
If you're creating an app on the backend and it contains models, you'll need to set up a couple of things to make sure migrations work. To begin with, in your app's models.py
make sure to import the app's declarative base and creating your models based off that:
from database import Base
class YourCoolModel(Base):
__tablename__ = "super_cool_models"
id = Column(Integer, primary_key=True, index=True)
# all your cool model attributes go here
After that, head over to alembic.env
and import your models on the top section of the file:
from users import models
from yourcoolapp import models
That's about it! Migrations should auto-generate correctly with that set up!
As part of our everyday work, data models may change from time to time. When you change a model in the backend, make sure to run the following code to generate any necessary Alembic migrations:
docker-compose run --rm api alembic revision --autogenerate -m "Migration name here!"
When possible, keep the migration name descriptive!
When a new migration file is available, apply it by running
./dev-setup.sh
If you want to run them manually you can also do:
docker-compose run --rm api alembic upgrade head
You can also roll back migrations by doing
docker-compose run --rm api alembic downgrade -1
To populate development database with seed data, which is located in /backend/almebic/seed_data
directory, run:
docker-compose run --rm api python alembic/seed.py
To add seed data or modify existing one, apply changes in <entity>.json
file for the target entity in aforementioned /backend/alembic/seed_data
directory. Make sure that the script uses the data you are
interested in, by checking the "files to be imported" at the top of the script.
All tests for the backed are within the /backend/tests
folder, and they're run automatically on branches and PRs by Travis. You can run them by doing:
docker-compose run --rm -e DATABASE_NAME='dbtest' api pytest
Builds are generated automatically whenever we:
master
(updates the dev
image)release/something
(updates an image called release/something-dev
)tag-name
image)After doing any of these actions, you can head over to Travis to see how the build is faring.
With the build ready, head over to Rancher to upgrade the Oasis instances in the environment you need to deploy to.
Make sure to:
db-migration
container if there is any new migration, app
container adding any necessary environment variables