---
# System prepended metadata

title: Deployment migration timeout

---

# Deployment migration timeout

## Introduction

During deploying sprint [82](https://github.com/HHS/TANF-app/pull/481) to production environment, the migrations hit time out due to disk space limit error.

During applying migrations, django 

## Adding new column with _default_ value

Django normally sets the default value at the ORM level (see [this](https://docs.djangoproject.com/en/4.2/ref/migration-operations/#alterfield)). This means the default values are set in the application level and not in database level.

## Resolve the deployment issue

To be able to resolve the issue, we will consider the following approaches:

1. Connect local app with remote DB and run the migration
2. Run SQL commands from cloud.gov prod instance


## 1. Connect to remote DB

The local terminal can be connected through a linked app to RDS (see [this](https://cloud.gov/docs/services/relational-database/))

Then local app can be connected using credentials provided with commands provided in above doc and run migrations.

![](https://hackmd.io/_uploads/Skv_z3CbT.png)



## 2. List SQL migration command

Each migration is applied by running a set of SQL commands. The SQL commands can be created using:

./manage.py sqlmigrate app_label migration_name


### Migrations in sprint 82

The following migrations have to run in sprint 82

* parsers/migrations/0007_datafilesummary.py
* search_indexes/migrations/0015_auto_20230724_1830.py
* search_indexes/migrations/0016_auto_20230803_1721.py
* search_indexes/migrations/0017_auto_20230914_1720.py

### List SQL commands for sprint 82 migrations

Listing the actual migration SQL commands requires connection to the prod DB, since the commands are created based on database state.

### Problem
When running SQL command directly, the migration table will not be updated. The _django_migrations_ table has to be updated manually.
