Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
lunakv committed Oct 2, 2022
1 parent 7ccfe31 commit addfa6b
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 73 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ It is used to power the [Academy Ruins](https://github.com/lunakv/academyruins)
### Installation
0. (recommended) Set up a virtual Python environment for the repository.
1. Set up Postgres and create a user and database for your API.
2. `cp .env_EXAMPLE .env`
3. (optional) Set up a [Pushover](https://pushover.net/) account and create an API token for the app.
2. (optional) Set up a [Pushover](https://pushover.net/) account and create an API token for the app.
3. `cp .env_EXAMPLE .env`
4. Adjust the values in your `.env` file according to your local configuration
5. `pip install -r requirements.txt`
6. Inside your virtual environment, run `./update_schema.sh` to load the current schema into the database.
5. Install [Poetry](https://python-poetry.org/), either globally or inside your venv.
6. (Inside your venv) run `poetry install`
7. (Inside your venv) run `./update_schema.sh` to load the current schema into the database.

### Run
- `uvicorn app.main:app --reload`
or
- `python devstart.py`
`python devstart.py`

The API server will start on port 8000 by default.

### Docker
There's a prepared `Dockerfile` and `docker-compose.yml` file you can inspect and use to run the API fully contained in a Docker container. Note that if you're running Postgres in a container and want to use `psql` from the host machine, you have to map port 5432 to the host and specify the `--host localhost` flag in any `psql` command in order to connect successfully.
### Containers
For production deployments, there's a prepared `Dockerfile` and `docker-compose.yml` file you can inspect and use to run the API fully contained in a Docker container. Note that if you're running Postgres in a container and want to use `psql` from the host machine, you have to map port 5432 to the host and specify the `--host localhost` flag in any `psql` command in order to connect successfully.

## Code Style
This project uses the [Black](https://black.readthedocs.io/en/stable/) code formatter. When working on code in this repository, it is recommended to set up a Black integration with your code editor. If your editor does not support Black, make sure to run `black .` before any commits to make sure all files are formatted correctly.
## Documentation
The full API docs are available at https://api.academyruins.com/docs

Expand Down
145 changes: 81 additions & 64 deletions alembic/versions/0cb715a5aac5_initial_autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,105 @@
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '0cb715a5aac5'
revision = "0cb715a5aac5"
down_revision = None
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('cr',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('creation_day', sa.Date(), nullable=True),
sa.Column('set_code', sa.String(length=5), nullable=True),
sa.Column('set_name', sa.String(length=50), nullable=True),
sa.Column('data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('file_name', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_table(
"cr",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("creation_day", sa.Date(), nullable=True),
sa.Column("set_code", sa.String(length=5), nullable=True),
sa.Column("set_name", sa.String(length=50), nullable=True),
sa.Column("data", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("file_name", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('cr_pending',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('creation_day', sa.Date(), nullable=True),
sa.Column('data', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('file_name', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_table(
"cr_pending",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("creation_day", sa.Date(), nullable=True),
sa.Column("data", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("file_name", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('ipg',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('creation_day', sa.Date(), nullable=True),
sa.Column('file_name', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_table(
"ipg",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("creation_day", sa.Date(), nullable=True),
sa.Column("file_name", sa.Text(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f('ix_ipg_creation_day'), 'ipg', ['creation_day'], unique=False)
op.create_table('mtr',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('file_name', sa.Text(), nullable=True),
sa.Column('creation_day', sa.Date(), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_index(op.f("ix_ipg_creation_day"), "ipg", ["creation_day"], unique=False)
op.create_table(
"mtr",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("file_name", sa.Text(), nullable=True),
sa.Column("creation_day", sa.Date(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f('ix_mtr_creation_day'), 'mtr', ['creation_day'], unique=False)
op.create_table('redirects',
sa.Column('resource', sa.Text(), nullable=False),
sa.Column('link', sa.Text(), nullable=False),
sa.PrimaryKeyConstraint('resource')
op.create_index(op.f("ix_mtr_creation_day"), "mtr", ["creation_day"], unique=False)
op.create_table(
"redirects",
sa.Column("resource", sa.Text(), nullable=False),
sa.Column("link", sa.Text(), nullable=False),
sa.PrimaryKeyConstraint("resource"),
)
op.create_table('redirects_pending',
sa.Column('resource', sa.Text(), nullable=False),
sa.Column('link', sa.Text(), nullable=False),
sa.PrimaryKeyConstraint('resource')
op.create_table(
"redirects_pending",
sa.Column("resource", sa.Text(), nullable=False),
sa.Column("link", sa.Text(), nullable=False),
sa.PrimaryKeyConstraint("resource"),
)
op.create_table('cr_diffs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('creation_day', sa.Date(), nullable=False),
sa.Column('changes', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column('source_id', sa.Integer(), nullable=False),
sa.Column('dest_id', sa.Integer(), nullable=False),
sa.Column('bulletin_url', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['dest_id'], ['cr.id'], ),
sa.ForeignKeyConstraint(['source_id'], ['cr.id'], ),
sa.PrimaryKeyConstraint('id')
op.create_table(
"cr_diffs",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("creation_day", sa.Date(), nullable=False),
sa.Column("changes", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("source_id", sa.Integer(), nullable=False),
sa.Column("dest_id", sa.Integer(), nullable=False),
sa.Column("bulletin_url", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["dest_id"],
["cr.id"],
),
sa.ForeignKeyConstraint(
["source_id"],
["cr.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('cr_diffs_pending',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('creation_day', sa.Date(), nullable=True),
sa.Column('source_id', sa.Integer(), nullable=False),
sa.Column('dest_id', sa.Integer(), nullable=False),
sa.Column('changes', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.ForeignKeyConstraint(['dest_id'], ['cr_pending.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['source_id'], ['cr.id'], ),
sa.PrimaryKeyConstraint('id')
op.create_table(
"cr_diffs_pending",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("creation_day", sa.Date(), nullable=True),
sa.Column("source_id", sa.Integer(), nullable=False),
sa.Column("dest_id", sa.Integer(), nullable=False),
sa.Column("changes", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.ForeignKeyConstraint(["dest_id"], ["cr_pending.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(
["source_id"],
["cr.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('cr_diffs_pending')
op.drop_table('cr_diffs')
op.drop_table('redirects_pending')
op.drop_table('redirects')
op.drop_index(op.f('ix_mtr_creation_day'), table_name='mtr')
op.drop_table('mtr')
op.drop_index(op.f('ix_ipg_creation_day'), table_name='ipg')
op.drop_table('ipg')
op.drop_table('cr_pending')
op.drop_table('cr')
op.drop_table("cr_diffs_pending")
op.drop_table("cr_diffs")
op.drop_table("redirects_pending")
op.drop_table("redirects")
op.drop_index(op.f("ix_mtr_creation_day"), table_name="mtr")
op.drop_table("mtr")
op.drop_index(op.f("ix_ipg_creation_day"), table_name="ipg")
op.drop_table("ipg")
op.drop_table("cr_pending")
op.drop_table("cr")
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tool.black]
line-length = 120

[tool.poetry]
name = "academyruins-api"
version = "0.1.0"
Expand Down

0 comments on commit addfa6b

Please sign in to comment.