GithubHelp home page GithubHelp logo

isapir / migrate2postgres Goto Github PK

View Code? Open in Web Editor NEW
52.0 11.0 25.0 115 KB

Easily migrate from other DBMSs to PostgreSQL

License: GNU General Public License v3.0

Java 100.00%
postgresql postgres migration migration-tool migrate-database

migrate2postgres's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

migrate2postgres's Issues

Foreignkey

I ran the application but apparently when it creates the tables it does not know how to add a foreign key. it's that correct? or the app should know how to handle the foreign keys?

lib.jaxb-api-2.3.0.jar error

When I run migrate.sh ı got following error. Do you guys have any idea?

./migrate.sh: line 5: -Dconnections.mssql.user=readonly: command not found
./migrate.sh: line 6: -Dconnections.mssql.password=secret: command not found
Error: Could not find or load main class lib.jaxb-api-2.3.0.jar

Regards

Support for Image Data Type

Hi,

There is not a sql_type_mapping for image by default.
I replace it with the 'bytea' data type but I still not check it if it is works.

OutOfMemory when copying a large table

hey,

I'm trying to use your tool for migrating my project from MSSQL to Postgres,
I've been able to migrate all of the tables and the data I had but one, that has about 20 millions records in it.

while running an attempt to migrate that specific table, I get the error-

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at net.twentyonesolutions.m2pg.PgMigrator.lambda$doDml$1(PgMigrator.java:155)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source)
at java.util.concurrent.CountedCompleter.exec(Unknown Source)
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.util.concurrent.ForkJoinTask.doInvoke(Unknown Source)
at java.util.concurrent.ForkJoinTask.invoke(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.forEach(Unknown Source)
at java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
at net.twentyonesolutions.m2pg.PgMigrator.doDml(PgMigrator.java:153)
at net.twentyonesolutions.m2pg.PgMigrator.main(PgMigrator.java:83)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source)
at java.lang.AbstractStringBuilder.append(Unknown Source)
at java.lang.StringBuilder.append(Unknown Source)
at net.twentyonesolutions.m2pg.Schema.copyTable(Schema.java:254)
at net.twentyonesolutions.m2pg.PgMigrator.lambda$doDml$0(PgMigrator.java:138)
at net.twentyonesolutions.m2pg.PgMigrator$$Lambda$17/6581689.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

is there any solution?

How avoid postgresql from folding to lowercase

I'm trying to move a legacy application's database from sql server to postgresql. I want to maintain the casing of the table and column names. Currently this is what the script the app is generating. I have trimmed the rest for brevity sake.

CREATE TABLE public.aspnet_Applications ( ApplicationName TEXT NOT NULL ,LoweredApplicationName TEXT NOT NULL ,ApplicationId CHAR(36) NOT NULL -- DEFAULT (newid()) ,Description TEXT );

After you run the script, all the table and column names will be converted to lowercase or uppercase or snake_case depending on the format you specify in the conf file. My question is, I want to know if there is a way to allow postgresql to maintain the same format for the table and column names as it was in the sql sever?

The datatype mapping doesn't works in some cases

Its a powerfull and awesome tool! I'm using this tool since February, 2022. Its perfect. But I'm taking some little erros, its a little effotr in replace on notepad++, for example, in the "sql_type_mapping" section, I would like to transform timestamp to bytea and datetime2 to timestamptz, and I put this code below:

"timestamp" : "bytea",
"datetime2" : "timestamptz",

But, when I check the DDL file, the datatypes for theses coluns remaing timpestamp and datetime2, and I need put on notepad++ and replace manually.

Another problem is a comment in a column, when we have a coment like this: "--Default value for table AS 0", the part of AS 0 is broke and putted in the another line, and occuring sintax errors.

All erros are easy to fix, and I made this fix everyday, its simple to fix. If necessary, I can send you prints and files.

org.postgresql.util.PSQLException: ERROR: relation does not exist

Trying to run the DML command and I get this type of error:

org.postgresql.util.PSQLException: ERROR: relation "public.vehicle_type" does not exist
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:473)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:393)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322)
        at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:279)
        at net.twentyonesolutions.m2pg.Schema.copyTable(Schema.java:125)
        at net.twentyonesolutions.m2pg.PgMigrator.lambda$doDml$0(PgMigrator.java:210)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

SCHEMA in uppercase

Hi

Thank you for this wonderful tool.

I have a huge db with camelcase tables - would love to see support for this as well since changing it now is not an option.

Thanks

How to select Windows Authentication in config file

In config file I see MS SQL Server authentication:
mssql : {
connectionString : "jdbc:sqlserver://localhost:1433"
,user : "%connections.mssql.user%"
,password : "%connections.mssql.password%"
,databaseName : "AdventureWorks"

How can I set Windows authentication?

Provide more information

Hi,

Request you to provide more information of using this tool like
Environment Windows or Linux?
Installation and configuration steps?
some sample report which are thing i can migrate or not migrate like in ora2pg we have.
details of command which we can use for migration from MSSQL to Postgres.

Thanks
Pawan

Other indices except PK?

Is it possible to add DDL indexes to each table?
I understand that Postgres has very wide possibilities for creating indexes, and in fact all the created indexes probably will make sense only as btree.
However, having a ready-made code sketch will be very useful.

Thank you.

Insert Failed. org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00

Insert is failing for NULL values. Can you please help here how we can fix this issue. Below is error message.

"Insert Failed. org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00

    INSERT INTO public.ANSWER_TYPE (ID, NAME)
    VALUES('1', '☺☺   ]?ùf°ß?6?FP?¬,Å?? →Cû???6-sg↔?W»');

Insert Failed. org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00"

Query to generate PKs

Hi,

I made a query to generate Pks of tables. The code is below:

SELECT DISTINCT 
         KCU.TABLE_SCHEMA
        ,KCU.TABLE_CATALOG
        ,KCU.TABLE_NAME
        ,'ALTER TABLE '+KCU.TABLE_SCHEMA + '.' + KCU.TABLE_NAME 
                +' CONSTRAINT '+  KCU.CONSTRAINT_NAME 
                +' PRIMARY KEY ("'+lower(KCU.COLUMN_NAME)+'");' as GENERATE_PK
FROM  INFORMATION_SCHEMA.TABLES T
    INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU ON
            T.TABLE_SCHEMA      = KCU.TABLE_SCHEMA
        AND T.TABLE_NAME        = KCU.TABLE_NAME
        AND T.TABLE_CATALOG     = KCU.TABLE_CATALOG
        AND OBJECTPROPERTY(OBJECT_ID(KCU.CONSTRAINT_SCHEMA + '.' + QUOTENAME(KCU.CONSTRAINT_NAME)), 'IsPrimaryKey') = 1
WHERE    T.TABLE_CATALOG        = '%information_schema.database_name%'
     AND T.TABLE_TYPE           = 'BASE TABLE'
     AND T.TABLE_NAME NOT IN ('dtproperties')
ORDER BY 1,2,3;

I hope this code help you to increase your solution.

Tks.

`

Casting data during DML

How do you cast data for certain columns during the DML process? I didn't see any example for that in your video or example files. for instance, I have data type "uniqueidentifier" mapped to "uuid" and log file recommends I cast the char value to uuid ..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.