Skip to content
This repository has been archived by the owner on Dec 22, 2020. It is now read-only.

Support more advanced schemas, including foreign keys #131

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

awreece
Copy link

@awreece awreece commented Nov 13, 2017

Is this project dead? I see no updates in a few years and all the pull requests are stale. Should I bother fixing the tests in my PR and trying to integrate it?

Summary

I'm starting to use mosql to migrate from mongodb with mongoose schemas to postgres. This diff has a number of improvements that were necessary for my migration:

  • Support for foreign keys on nested schemas
  • ObjectId is now stored as bytea
  • Support for array types
  • Support for :default, :notnull, etc
  • Better bulk insert support (and perf) via the the use of Sequel::Database##multi_insert

Examples

This corresponds to the following:

var ChildrenSchema = new mongoose.Schema({
    name: { type: String }
});

var TestSchema = new mongoose.Schema({
    name: { type: String },
    tags: [{ type: String }],
    balance: { type: Number },
    meta: { type: Object },
    children: [ ChildrenSchema ]
});
alphaflow:
    test:
        :columns:
        - id:
          :source: _id
          :type: bytea 
          :notnull: true
        - name:
          :source: name
          :type: text
        - tags:
          :source: tags
          :type: text array
        - balance:
          :source: balance
          :type: int
        - meta:
          :source: meta
          :type: jsonb
        :meta:
          :table: test 
          :schema: alphaflow
        :children:
          :meta:
            :table: test_children
            :schema: alphaflow
          :columns:
          - id:
            :source: _id
            :type: bytea not null
          - name:
            :source: name
            :type: text

Testing done

A bunch of manual testing, including on some rather complex schemas.

Note this diff is not safe to integrate, as it broke most of the unit tests

 - Insert object ids as raw binary
 - Support for default values and not null
 - More rational quoting for binary data
@nelhage-stripe
Copy link

Hey @awreece,

Unfortunately, Stripe hasn't used this project in some time and so it's been mostly unmaintained. If you happen to be interested in taking on ownership+maintenance, we'd potentially be willing to chat about that, but otherwise we probably won't be able to review this PR.

@awreece
Copy link
Author

awreece commented Nov 14, 2017

Thanks for the quick reply!

Good to know. We're not the right long term maintainers of this tool -- we view it as a way to migrate off of mongodb and so we'd abandon maintenance shortly as well.

Feel free to close the PR, but I'm also happy to just leave it open and visible in the main project -- maybe some future company will see it and want to pick up where we leave off.

@CLAassistant
Copy link

CLAassistant commented Aug 6, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ awreece
❌ joshbeam
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants