Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Migration #25

Open
tanishapatil1234 opened this issue Jul 25, 2024 · 0 comments
Open

Schema Migration #25

tanishapatil1234 opened this issue Jul 25, 2024 · 0 comments

Comments

@tanishapatil1234
Copy link
Contributor

tanishapatil1234 commented Jul 25, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant