Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

#215 blackを導入 #217

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
python3 -m venv venv
source ./venv/bin/activate
pip install -U pip setuptools tox
tox -epy38,flake8_ci
tox -e py38,lint_ci
- save_cache:
paths:
- ./venv
Expand Down
2 changes: 1 addition & 1 deletion ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Unreleased
Release Notes - 2020-11-02
--------------------------
- [#213] リリースノートの最新バージョンの記述を返すversionコマンドを追加

- [#215] blackの導入

Release Notes - 2020-10-30
--------------------------
Expand Down
21 changes: 10 additions & 11 deletions src/alembic/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Baseをimportするのでharoのrootパスを追加
# NOTE: run.py と統合できない?
root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.append(root)

# this is the Alembic Config object, which provides
Expand All @@ -26,8 +26,9 @@

# ini ファイルに環境変数を渡すことができないため、ここで追加
from slackbot_settings import SQLALCHEMY_URL, SQLALCHEMY_ECHO
config.set_main_option('sqlalchemy.url', SQLALCHEMY_URL)
config.set_main_option('sqlalchemy.echo', SQLALCHEMY_ECHO)

config.set_main_option("sqlalchemy.url", SQLALCHEMY_URL)
config.set_main_option("sqlalchemy.echo", SQLALCHEMY_ECHO)

# Interpret the config file for Python logging.
# This line sets up loggers basically.
Expand Down Expand Up @@ -64,8 +65,7 @@ def run_migrations_offline():

"""
url = config.get_main_section["sqlalchemy.url"]
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True)
context.configure(url=url, target_metadata=target_metadata, literal_binds=True)

with context.begin_transaction():
context.run_migrations()
Expand All @@ -80,18 +80,17 @@ def run_migrations_online():
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)

with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
)
context.configure(connection=connection, target_metadata=target_metadata)

with context.begin_transaction():
context.run_migrations()


if context.is_offline_mode():
run_migrations_offline()
else:
Expand Down
22 changes: 12 additions & 10 deletions src/alembic/migrations/versions/8e7a2acd24b8_add_resource_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@


# revision identifiers, used by Alembic.
revision = '8e7a2acd24b8'
down_revision = '919388975e00'
revision = "8e7a2acd24b8"
down_revision = "919388975e00"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('resource',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('channel_id', sa.Unicode(length=249), nullable=False),
sa.Column('name', sa.Unicode(length=249), nullable=False),
sa.Column('status', sa.Unicode(length=249), nullable=True),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"resource",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("channel_id", sa.Unicode(length=249), nullable=False),
sa.Column("name", sa.Unicode(length=249), nullable=False),
sa.Column("status", sa.Unicode(length=249), nullable=True),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('resource')
op.drop_table("resource")
# ### end Alembic commands ###
191 changes: 104 additions & 87 deletions src/alembic/migrations/versions/919388975e00_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,113 +10,130 @@


# revision identifiers, used by Alembic.
revision = '919388975e00'
revision = "919388975e00"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('cleaning',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('slack_id', sa.Unicode(length=11), nullable=False),
sa.Column('day_of_week', sa.Integer(), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"cleaning",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("slack_id", sa.Unicode(length=11), nullable=False),
sa.Column("day_of_week", sa.Integer(), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('create_command',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=100), nullable=False),
sa.Column('creator', sa.Unicode(length=100), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('name')
op.create_table(
"create_command",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=100), nullable=False),
sa.Column("creator", sa.Unicode(length=100), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name"),
)
op.create_table('kintai_history',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Unicode(length=100), nullable=False),
sa.Column('is_workon', sa.Boolean(), nullable=True),
sa.Column('registered_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"kintai_history",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Unicode(length=100), nullable=False),
sa.Column("is_workon", sa.Boolean(), nullable=True),
sa.Column("registered_at", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('kudo_history',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.Unicode(length=100), nullable=False),
sa.Column('from_user_id', sa.Unicode(length=100), nullable=False),
sa.Column('delta', sa.Integer(), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"kudo_history",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.Unicode(length=100), nullable=False),
sa.Column("from_user_id", sa.Unicode(length=100), nullable=False),
sa.Column("delta", sa.Integer(), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('redbull_history',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Unicode(length=100), nullable=False),
sa.Column('delta', sa.Integer(), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"redbull_history",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Unicode(length=100), nullable=False),
sa.Column("delta", sa.Integer(), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('redmine_projectchannel',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('project_id', sa.Integer(), nullable=True),
sa.Column('channels', sa.Unicode(length=249), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('project_id')
op.create_table(
"redmine_projectchannel",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("project_id", sa.Integer(), nullable=True),
sa.Column("channels", sa.Unicode(length=249), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("project_id"),
)
op.create_table('redmine_users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Unicode(length=9), nullable=False),
sa.Column('api_key', sa.Unicode(length=40), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('api_key'),
sa.UniqueConstraint('user_id')
op.create_table(
"redmine_users",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Unicode(length=9), nullable=False),
sa.Column("api_key", sa.Unicode(length=40), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("api_key"),
sa.UniqueConstraint("user_id"),
)
op.create_table('thx_history',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Unicode(length=100), nullable=False),
sa.Column('from_user_id', sa.Unicode(length=100), nullable=False),
sa.Column('word', sa.Unicode(length=1024), nullable=False),
sa.Column('channel_id', sa.Unicode(length=100), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"thx_history",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Unicode(length=100), nullable=False),
sa.Column("from_user_id", sa.Unicode(length=100), nullable=False),
sa.Column("word", sa.Unicode(length=1024), nullable=False),
sa.Column("channel_id", sa.Unicode(length=100), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('user_alias_name',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('slack_id', sa.Unicode(length=100), nullable=False),
sa.Column('alias_name', sa.Unicode(length=100), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('alias_name')
op.create_table(
"user_alias_name",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("slack_id", sa.Unicode(length=100), nullable=False),
sa.Column("alias_name", sa.Unicode(length=100), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("alias_name"),
)
op.create_table('water_history',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Unicode(length=100), nullable=False),
sa.Column('delta', sa.Integer(), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"water_history",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.Unicode(length=100), nullable=False),
sa.Column("delta", sa.Integer(), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('term',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('create_command', sa.Integer(), nullable=True),
sa.Column('word', sa.Unicode(length=1024), nullable=False),
sa.Column('creator', sa.Unicode(length=100), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['create_command'], ['create_command.id'], onupdate='CASCADE', ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('word')
op.create_table(
"term",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("create_command", sa.Integer(), nullable=True),
sa.Column("word", sa.Unicode(length=1024), nullable=False),
sa.Column("creator", sa.Unicode(length=100), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(
["create_command"],
["create_command.id"],
onupdate="CASCADE",
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("word"),
)
### end Alembic commands ###


def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_table('term')
op.drop_table('water_history')
op.drop_table('user_alias_name')
op.drop_table('thx_history')
op.drop_table('redmine_users')
op.drop_table('redmine_projectchannel')
op.drop_table('redbull_history')
op.drop_table('kudo_history')
op.drop_table('kintai_history')
op.drop_table('create_command')
op.drop_table('cleaning')
op.drop_table("term")
op.drop_table("water_history")
op.drop_table("user_alias_name")
op.drop_table("thx_history")
op.drop_table("redmine_users")
op.drop_table("redmine_projectchannel")
op.drop_table("redbull_history")
op.drop_table("kudo_history")
op.drop_table("kintai_history")
op.drop_table("create_command")
op.drop_table("cleaning")
### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,44 @@


# revision identifiers, used by Alembic.
revision = '98ecbc1e5b66'
down_revision = '8e7a2acd24b8'
revision = "98ecbc1e5b66"
down_revision = "8e7a2acd24b8"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('emergency_timeline',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('created_by', sa.Unicode(length=9), nullable=False),
sa.Column('room', sa.Unicode(length=9), nullable=False),
sa.Column('title', sa.Unicode(length=128), nullable=False),
sa.Column('is_closed', sa.BOOLEAN(), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.Column('utime', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"emergency_timeline",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_by", sa.Unicode(length=9), nullable=False),
sa.Column("room", sa.Unicode(length=9), nullable=False),
sa.Column("title", sa.Unicode(length=128), nullable=False),
sa.Column("is_closed", sa.BOOLEAN(), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.Column("utime", sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table('timeline_log',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('timeline_id', sa.Integer(), nullable=False),
sa.Column('created_by', sa.Unicode(length=9), nullable=False),
sa.Column('ctime', sa.DateTime(), nullable=False),
sa.Column('utime', sa.DateTime(), nullable=False),
sa.Column('entry', sa.Text(), nullable=False),
sa.ForeignKeyConstraint(['timeline_id'], ['emergency_timeline.id'], ),
sa.PrimaryKeyConstraint('id')
op.create_table(
"timeline_log",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("timeline_id", sa.Integer(), nullable=False),
sa.Column("created_by", sa.Unicode(length=9), nullable=False),
sa.Column("ctime", sa.DateTime(), nullable=False),
sa.Column("utime", sa.DateTime(), nullable=False),
sa.Column("entry", sa.Text(), nullable=False),
sa.ForeignKeyConstraint(
["timeline_id"],
["emergency_timeline.id"],
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('timeline_log')
op.drop_table('emergency_timeline')
op.drop_table("timeline_log")
op.drop_table("emergency_timeline")
# ### end Alembic commands ###
Loading