Skip to content

Commit

Permalink
Increase the column width of the subscription role column (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
agxs committed Aug 24, 2021
1 parent d913a52 commit ae56bfe
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LABEL commit=${COMMIT}
WORKDIR /usr/src/app

# Sqlite for testing
RUN apt update && apt install sqlite -y && rm -rf /var/lib/apt/lists/*
RUN apt update && apt install sqlite3 -y && rm -rf /var/lib/apt/lists/*

# Supervisord
RUN pip install supervisor
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,20 @@ Documentation currently in [docs/](docs/) - should be in readthedocs

# Installing

Nbexchange can be installed as a Helm chart
Nbexchange can be installed as a Helm chart or as a pip dependency:

## Configuration

```
helm install --name nbexchange --namespace default ./chart -f myconfiguration.yaml
```

or

```
pip install .
```

## Helm Configuration

| Parameter | Description | Default |
| ---------- | -------------- | ------- |
Expand All @@ -87,12 +98,6 @@ Nbexchange can be installed as a Helm chart
| `nodeSelector` | Pod node selector for deployment | `{}` |


## How to

```
helm install --name nbexchange --namespace default ./chart -f myconfiguration.yaml
```

# Contributing

See [Contributing.md](CONTRIBUTING.md)
Expand Down
2 changes: 1 addition & 1 deletion nbexchange/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ script_location = {alembic_dir}
sqlalchemy.url = {db_url}

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
file_template = %%(year)d-%%(month).2d-%%(day).2d-%%(hour).2d-%%(minute).2d-%%(second).2d_%%(slug)s

# timezone to use when rendering the date
# within the migration file as well as the filename.
Expand Down
1 change: 0 additions & 1 deletion nbexchange/alembic/README

This file was deleted.

15 changes: 15 additions & 0 deletions nbexchange/alembic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generic single-database configuration.

## Building migrations:

Build a fresh database

`NBEX_DB_URL="sqlite:///test.db" nbexchange`

Create a migration:

`NBEX_DB_URL="sqlite:///test.db" python -m nbexchange.dbutil alembic revision --autogenerate -m "Change subscription column width"`

Apply a migration:

`NBEX_DB_URL="sqlite:///test.db" python -m nbexchange.dbutil alembic upgrade head`
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Change subscription column width
Revision ID: 2540572282f2
Revises: bfe19408f64f
Create Date: 2021-08-20 15:24:21.878350
"""
from alembic import op


# revision identifiers, used by Alembic.
revision = "2540572282f2"
down_revision = "bfe19408f64f"
branch_labels = None
depends_on = None


def upgrade():
op.execute("ALTER TABLE subscription ALTER COLUMN role TYPE Text")


def downgrade():
op.execute("ALTER TABLE subscription ALTER COLUMN role TYPE VARCHAR(50)")
11 changes: 9 additions & 2 deletions nbexchange/models/subscriptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from sqlalchemy import Column, ForeignKey, Integer, Unicode, UniqueConstraint
from sqlalchemy import (
Column,
ForeignKey,
Integer,
Unicode,
UniqueConstraint,
UnicodeText,
)
from sqlalchemy.orm import relationship

from nbexchange.models import Base
Expand All @@ -25,7 +32,7 @@ class Subscription(Base):
id = Column(Integer, primary_key=True, autoincrement=True)
user_id = Column(Integer, ForeignKey("user.id", ondelete="CASCADE"), index=True)
course_id = Column(Integer, ForeignKey("course.id", ondelete="CASCADE"), index=True)
role = Column(Unicode(50), nullable=False)
role = Column(UnicodeText, nullable=False)

# These are the relationship handles: a specific subscription has a single user to a single course
user = relationship("User", back_populates="courses")
Expand Down

0 comments on commit ae56bfe

Please sign in to comment.