Skip to content

Schema Migration #25

@tanishapatil1234

Description

@tanishapatil1234

Step 1: Dump JSON from Old Database via API

  1. Use an API endpoint to fetch the data from old database.
  2. Ensure you have proper authentication token
  3. Save the fetched data in a JSON file.

fetch_data.py : https://github.com/nighthawkcoders/flask_2025/blob/main/scripts/fetch_data.py

image image

Step 2: Update Schema from New Development using python db_init.py and SQLite3 Extension

  1. Ensure db_init.py script contains the latest schema definitions.
  2. Run the db_init.py script to update the SQLite database schema.

Not sure if this is completely correct, but this is a script for creating new versions of the three related tables in order to create new RDS database later on ...

db_initi.py : https://github.com/nighthawkcoders/flask_2025/blob/main/scripts/db_init.py

The schema in this file should be directly edited to make changes in schema. The other way, is to directly change the schema in the model/user.py file and rerun the init_db.py file

Step 3: Connect to RDS and Create New Database with Schema

  1. Connect to Your RDS Instance: Use a db client to connect to your RDS instance.
  2. Create a New Database: Create a new database in RDS instance.
  3. Apply the Schema

rds_init.py : https://github.com/nighthawkcoders/flask_2025/blob/main/scripts/rds_init.py

Step 4: Update JSON into New Database

  1. Read the JSON Data: Load the JSON data from the file you created in Step 1
  2. Connect to the New RDS Database: Establish a connection to the RDS instance where the new database is located.
  3. Insert Data into the New Database: Populate the new database tables with the JSON data.

update_data.py : https://github.com/nighthawkcoders/flask_2025/blob/main/scripts/update_data.py

Sciprts for migration should be run in this order :

  1. fetch_data.py
  2. db_init.py (CUSTOMIZE)
  3. rds_init.py (CUSTOMIZE)
  4. update_data.py (CUSTOMIZE BASED ON rds_init.py)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions