All Projects → MadeByMads → mad-migration

MadeByMads / mad-migration

Licence: MIT license
Database migration tool for migrate different structured databases.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to mad-migration

alembic utils
An alembic/sqlalchemy extension for migrating sql views, functions, triggers, and policies
Stars: ✭ 105 (+262.07%)
Mutual labels:  sqlalchemy, alembic
graygram-web
www.graygram.com
Stars: ✭ 16 (-44.83%)
Mutual labels:  sqlalchemy, alembic
fast-api-sqlalchemy-template
Dockerized web application on FastAPI, sqlalchemy1.4, PostgreSQL
Stars: ✭ 25 (-13.79%)
Mutual labels:  sqlalchemy, alembic
pyramid-cookiecutter-alchemy
[DEPRECATED - Please use https://github.com/pylons/pyramid-cookiecutter-starter instead] A Cookiecutter (project template) for creating a Pyramid project using SQLite for persistent storage, SQLAlchemy for an ORM, Alembic for database migrations, URL dispatch for routing, and Jinja2 for templating.
Stars: ✭ 39 (+34.48%)
Mutual labels:  sqlalchemy, alembic
cloudrun-fastapi
FastAPI on Google Cloud Run
Stars: ✭ 112 (+286.21%)
Mutual labels:  sqlalchemy, alembic
flask-db
A Flask CLI extension to help migrate and manage your SQL database.
Stars: ✭ 56 (+93.1%)
Mutual labels:  sqlalchemy, alembic
Aiomysql
aiomysql is a library for accessing a MySQL database from the asyncio
Stars: ✭ 1,252 (+4217.24%)
Mutual labels:  sqlalchemy, mariadb
nest-rest-typeorm-boilerplate
🍱 backend with nest (typescript), typeorm, and authentication
Stars: ✭ 142 (+389.66%)
Mutual labels:  mariadb
flask for startups
Flask boilerplate using a services oriented structure
Stars: ✭ 210 (+624.14%)
Mutual labels:  sqlalchemy
sqlalchemy-utc
SQLAlchemy type to store aware datetime values
Stars: ✭ 87 (+200%)
Mutual labels:  sqlalchemy
FastAPI-template
Feature rich robust FastAPI template.
Stars: ✭ 660 (+2175.86%)
Mutual labels:  alembic
SQL-for-Data-Analytics
Perform fast and efficient data analysis with the power of SQL
Stars: ✭ 187 (+544.83%)
Mutual labels:  sqlalchemy
MirrorCache
Download Redirector
Stars: ✭ 24 (-17.24%)
Mutual labels:  mariadb
LEMPer
LEMPer Stack is terminal-based LEMP / LNMP installer and manager for Debian & Ubuntu cloud or virtual server (vps) and on-premise (bare metal).
Stars: ✭ 171 (+489.66%)
Mutual labels:  mariadb
DBD-MariaDB
Perl MariaDB driver
Stars: ✭ 28 (-3.45%)
Mutual labels:  mariadb
EasyProfiler
This repo, provides query profiler for .Net
Stars: ✭ 99 (+241.38%)
Mutual labels:  mariadb
akk-stack
Containerized EverQuest Emulator Server Environment
Stars: ✭ 36 (+24.14%)
Mutual labels:  mariadb
easydock
Dockerize your PHP apps ;)
Stars: ✭ 52 (+79.31%)
Mutual labels:  mariadb
r2dbc-migrate
R2DBC database migration tool & library
Stars: ✭ 83 (+186.21%)
Mutual labels:  mariadb
apistar alembic migrations
Alembic migrations for apistar
Stars: ✭ 18 (-37.93%)
Mutual labels:  alembic

Project logo

Database Migration Tool

Status GitHub Issues GitHub Pull Requests License

Don't use this tool in production databases!! At this time tool under development!!

🧐 About

The Database Migration Tool was designed for those looking to migrate their data from one database to another. Basically, the tool is focused on transferring data from different database structures. Currently, the MySQL, Mariadb and Postgres driver related tool allows us to add NoSQL to SQL databases and vice versa. Our main goal is to make data migration possible in all environments.


Documentation: Documentation

🏁 Getting Started

Installing

pip install madmigration

🎈 Usage

After installation you should define YAML file where configuration will be taken in order to apply data to target database. Yaml file with list and dictionaries may contain following structures:

alt text

Connection Config

  • SourceConfig is intented to be data from source database
  • DestinationConfig is intented to be transfered data to target database
version: 0.1.6
Configs:
  - SourceConfig:
       dbURI: "postgres://root:[email protected]/oldDB"
  - DestinationConfig:
       dbURI: "mysql://root:[email protected]/newDB"

migrationTables:
  - migrationTable:
      SourceTable:
        name: users
      DestinationTable:
        name: persons
        create: True

      MigrationColumns:
        - sourceColumn:
            name: id
          destinationColumn:
            name: id
            options:
              type_cast: bigint
              primary_key: true
              autoincrement: true

        - sourceColumn:
            name: name
          destinationColumn:
            name: fname
            options:
              type_cast: varchar
              length: 32
      
        - sourceColumn:
            name: surname
          destinationColumn:
            name: lname
            options:
              type_cast: varchar
              length: 32
              index: true

        - sourceColumn:
            name: age
          destinationColumn:
            name: age
            options:
              type_cast: int

        - sourceColumn:
            name: createdAT
          destinationColumn:
            name: created_at
            options:
              type_cast: datetime

        - sourceColumn:
            name: updatedAT
          destinationColumn:
            name: updated_at
            options:
              type_cast: datetime

Configs section

  • SourceConfig set the source database database configurations
    • dbURI source database URI
  • DestinationConfig set the destination database configurations
    • dbURI destination database URI
Configs:
  - SourceConfig:
       dbURI: "postgres://root:[email protected]/oldDB"  # set source database uri
  - DestinationConfig:
       dbURI: "mysql://root:[email protected]/newDB"  # set destination database uri

migrationTables section

  • migrationTables in this configuration, you will write the source of the table that you have to migrate and the destination tables that will migrate the data.
    • migrationTable specify the source and destination table name
      • SourceTable information about source table
        • name source table name
      • DestinationTable information about destination table
        • name destination table name
        • create bool value. This parameter tells the program whether it should create a table or not. (default false)
migrationTables:
  - migrationTable:
      SourceTable:
        name: users
      DestinationTable:
        name: persons
        create: True

MigrationColumns section

  • MigrationColumns specify source and destination column
    • sourceColumn information about source column
      • name source column name
    • destinationColumn information about destination column
      • name destination column name
      • options column options
        • type_cast destination column type name varchar,integer etc. (when we convert data we use this parameter)
MigrationColumns:
  - sourceColumn:
      name: id
    destinationColumn:
      name: id
      options:
        type_cast: bigint
        primary_key: true
        autoincrement: true

If you want to create a foreign key you can specify it in the column parameters

- sourceColumn:
    name: USERID
  destinationColumn:
    name: user_id
    options:
      type_cast: uuid
      foreign_key:
        table_name: users
        column_name: id
        ondelete: CASCADE

You can split your .yaml files or import .json file into .yaml file.

You must create the main .yaml file and importing other files into main .yaml file.

main.yaml file

version: 1.1
Configs:
  - SourceConfig:
      dbURI: "mysql://root:[email protected]/old"
  - DestinationConfig:
      dbURI: "postgresql://root:[email protected]/new"

migrationTables:
  - migrationTable: !import company.yaml
  - migrationTable: !import op_cond.json

company.yaml file

SourceTable:
  name: company
DestinationTable:
  name: company
  create: true 

MigrationColumns:
  - sourceColumn:
      name: id
    destinationColumn: 
      name: id
      options:
        primary_key: true
        type_cast: uuid

  - sourceColumn:
      name: name
    destinationColumn:
      name: name
      options:
        length: 120
        type_cast: varchar
        nullable: false

  - sourceColumn:
      name: created
    destinationColumn:
      name: created
      options:
        type_cast: datetime
  - sourceColumn:
      name: updated
    destinationColumn:
      name: updated
      options:
        type_cast: datetime
        nullable: true

op_conds.json file

{
    "SourceTable": {
      "name": "operation_conditions"
    },
    "DestinationTable": {
      "name": "operation_conditions",
      "create": true
    },
    "MigrationColumns": [
      {
        "sourceColumn": {
          "name": "id"
        },
        "destinationColumn": {
          "name": "id",
          "options": {
            "primary_key": true,
            "type_cast": "uuid"
          }
        }
      },
      {
        "sourceColumn": {
          "name": "interest"
        },
        "destinationColumn": {
          "name": "interest",
          "options": {
            "type_cast": "varchar",
            "length": 30,
            "nullable": false
          }
        }
      },
      {
        "sourceColumn": {
          "name": "FIFD"
        },
        "destinationColumn": {
          "name": "FIFD",
          "options": {
            "type_cast": "varchar",
            "length": 30,
            "nullable": false
          }
        }
      },
      {
        "sourceColumn": {
          "name": "comission"
        },
        "destinationColumn": {
          "name": "comission",
          "options": {
            "type_cast": "varchar",
            "length": 30,
            "nullable": false
          }
        }
      }
    ]
  }

Currently new feature PostgreSql to MongoDB has been added.

version: 1.1
Configs:
  - SourceConfig:
      dbURI: "postgresql://sabuhi:sabuhi12345@localhost:5432/company_service"
  - DestinationConfig:
      dbURI: "mongodb://localhost:27017/mydb"

migrationTables:
  - migrationTable:
      SourceTable:  #postgresql table name
        name: company  
      DestinationTable: #the collection name:
        name: Company

      MigrationColumns:
        - sourceColumn:
            name: id
          destinationColumn:
            name: id
            options:
              type_cast: uuid

        - sourceColumn:
            name: name
          destinationColumn:
            name: NAME
            options:
              type_cast: varchar
              
        - sourceColumn:
            name: created
          destinationColumn:
            name: CREATED
            options:    
              type_cast: datetime
        - sourceColumn:
            name: email
          destinationColumn:
            name: EMAIL
            options:     
              type_cast: string
        - sourceColumn:
            name: updated
          destinationColumn:
            name: UPDATED
            options:
              type_cast: datetime
         - sourceColumn:
            name: code
          destinationColumn:
            name: CODE
            options:      
              type_cast: string

Work on PostgreSQl to MongoDB still goes, we will add other futures as soon as possible.

We will create all tables and database on the destination server if they do not exist

madmigrate -f migration_schema.yaml

✍️ Authors

See also the list of contributors who participated in this project.

Contributing

We are open to new ideas, additions. If you have any we would be happy to recieve and diccuss.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].