nighthawkcoders / flask_2025

This project is a web application for managing Classroom instruction and operations. It is built using Flask, SQLAlchemy, and other requirements.txt dependencies.
https://flask2025.nighthawkcodingsociety.com/
0 stars 12 forks source link

Final Documentation for All Migration/RDS Scripts #33

Open tanishapatil1234 opened 3 months ago

tanishapatil1234 commented 3 months ago

Database Migration Scripts Documentation

Overview

This documentation provides details on the two primary scripts used for migrating the RDS database: db_init.py and db_migrate.py. These scripts are designed to initialize the database schema and migrate data from an old database to a new one.


db_init.py

Description

The db_init.py script is responsible for initializing the database schema. It performs the following steps:

  1. Warning the User: Alerts the user about potential data loss.
  2. Database Backup: Backs up the current database to a specified location.
  3. Schema Initialization: Drops any existing tables and creates new ones based on the defined schema.
  4. Data Loading: Adds default test data to the newly created tables.

Usage

Run the script from the terminal :

cd scripts; ./db_init.py

Functions

Important Notes

db_migrate.py

Description

The db_migrate.py script is responsible for migrating data from an old database to a new one. It follows these steps:

  1. Warning the User: Alerts the user about potential data loss.
  2. Database Backup: Backs up the current database to a specified location.
  3. Schema Initialization: Drops existing tables and creates new ones based on the defined schema.
  4. Data Migration: Authenticates with the old database, extracts data, and loads it into the new database.

Usage

Run the script from the terminal :

cd scripts; ./db_migrate.py

Functions

backup_database(db_uri, backup_uri, db_string)

create_database(engine, db_name)

extract_data(cookies)

write_data_to_json(data, json_file)

read_data_from_json(json_file)

main()

Important Notes