Skip to content

Commit

Permalink
Update alembic migration files for sqlalchemy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tuncbkose committed Jun 16, 2023
1 parent c6ceb80 commit 59503d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions nbgrader/alembic/versions/167914646830_added_task_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def upgrade():
)

connection = op.get_bind()
results = connection.execute(sa.select([
results = connection.execute(sa.select(
old_grade_table.c.name,
old_grade_table.c.id,
old_grade_table.c.cell_type,
old_grade_table.c.notebook_id,
old_grade_table.c.max_score
])).fetchall()
)).fetchall()

# copy info to the base_cell table
base_grade_cells = [
Expand All @@ -109,11 +109,11 @@ def upgrade():
op.bulk_insert(new_grade_table, grade_cells)

# now transfer the solution cells...
results = connection.execute(sa.select([
results = connection.execute(sa.select(
old_solution_table.c.name,
old_solution_table.c.id,
old_solution_table.c.notebook_id,
])).fetchall()
)).fetchall()

# copy info to the base_cell table
base_solution_cells = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ def upgrade():

# If the course table is empty, create a default course
connection = op.get_bind()
res = connection.execute("select id from course")
res = connection.execute(sa.text("select id from course"))
results = res.fetchall()
default_course = "default_course"

if len(results) == 0:
connection.execute(
"INSERT INTO course (id) VALUES ('{}')".format(default_course))
sa.text("INSERT INTO course (id) VALUES ('{}')".format(default_course))
)

with op.batch_alter_table("assignment") as batch_op:

Expand Down

0 comments on commit 59503d0

Please sign in to comment.