ChangeDB is a multi-database cli convert tool, it's all about making database migration much more easier.
- Install Dotnet (net5/net6).
ChangeDB
is supported by dotnet sdk, please check the link Here to setup your personal dotnet sdk. - Install ChangeDB tool. you can follow the command below to setup tool quite easily.
dotnet tool install ChangeDB.ConsoleApp -g
- Database converting. you can use
changedb migration
command convert database. Like the example command below, you need to provide source database type, source database connection string, target database type and target database connection string to establish migrate task. and for target database,changedb
tool has the ability to create a new target database even if not exists. so you don't create a empty database everytime first.changedb migration {source-database-type} "{source-connection-string}" {target-database-type} "{target-connection-string}"
- Dump database to sql scripts,
changedb
tool also has the ability to generate sql scripts. you can usechangedb dumpsql
command,Like the example example below to create sql scripts.changedb dumpsql {source-database-type} "{source-connection-string}" {target-database-type} "{output-file}"
- Here we use Northwind.sql as source data to show how we migrate between different type of database
- Sql Server
- Postgres
- Mysql
- Sql Server Compact (only supported in windows)
Database | Format connection string | Extend usages |
---|---|---|
Sql Serve | Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword; |
Link |
Postgres | Server=127.0.0.1;Port=5432;Database=myDataBase;User Id=myUsername;Password=myPassword; |
Link |
Mysql | Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; |
Link |
Sql Server Compact | Data Source=MyData.sdf;Persist Security Info=False; |
Link |
Category | Object | Sql Server | Postgres | Mysql | Sql Server Compact |
---|---|---|---|---|---|
Table | identity |
✔️ | ✔️ | ✔️ | ✔️ |
Table | index |
✔️ | ✔️ | ✔️ | ✔️ |
Table | unique |
✔️ | ✔️ | ✔️ | ✔️ |
Table | default constant value |
✔️ | ✔️ | ✔️ | ✔️ |
Table | default function value |
✔️(newid ,getdate ) |
✔️(gen_random_uuid ,now ) |
✔️(uuid ,now ) |
✔️(newid ,getdate ) |
Table | foreign key |
✔️ | ✔️ | ✔️ | ✔️ |
Table | unique index |
✔️ | ✔️ | ✔️ | ✔️ |