Mosql (mosql v0.1.0)

Specification for Mosql. It is used to export data from MongoDB database to Postgres database

There are two kind of Mosql exports: full export and change stream

fullexport

FullExport

FullExport is used to do a one time full export of MongoDB database to a destination Postgres database using the schema mapping definitions that maps each collection and document fields to SQL table and table attributes. The process to start the export:

  1. Create a postgres export type with a namespace. Namespace has to be unique
Mosql.create_postgres_export("my_namespace")

The export can be customized by using the `options` argument
to provide `exclusions` and `exclusives`
 * `:exclusions` - the list of collections to exclude from the export
 * `:exclusives` - the list of collections that must be included
  1. Generate export schema definitions and export to a file system ex = Mosql.generate_default_schemas(export, [persist: true, export_path: "schema"]) Export.to_json(ex, "schema")

  2. Reload the (updated) schema files from the path to the export Mosql.reload_schema_files(export, schema_path)

  3. Trigger full export Mosql.start_full_export(export)

Link to this section Summary

Functions

creates the complete postgres type export definition for the given namespace

Fetch the postgres export based on the namespace and the type

Generates the default export schema definitions for the given export. These schema definitions can be modified to customize the export at the collection and field level. It takes additional opts to provide export_path and persist

Loads the saved export to the schema store for the export

Reload the schema definition from the JSON files to the given export from the file path. This will override the existing in-memory schema definition associated with the export

Removes the saved export based on the namespace and type

Perform one time setup operation for MoSQL to initialize export database and other things

Start the full export process for the given export

Link to this section Functions

Link to this function

create_postgres_export(namespace, options \\ [])

creates the complete postgres type export definition for the given namespace

Link to this function

fetch_postgres_export(namespace)

Fetch the postgres export based on the namespace and the type

Link to this function

generate_default_schemas(export, opts \\ [])

Generates the default export schema definitions for the given export. These schema definitions can be modified to customize the export at the collection and field level. It takes additional opts to provide export_path and persist

 * `:export_path` - export the schema as JSON files on the given export path
 * `:persist` - persist export definition in the MoSQL internal store

MoSQL internal store is a mnesia based disk store. See Mosql.Export.setup!() for more details

Link to this function

load_postgres_export(namespace)

Loads the saved export to the schema store for the export

Link to this function

reload_schema_files(export, schema_path)

Reload the schema definition from the JSON files to the given export from the file path. This will override the existing in-memory schema definition associated with the export

Link to this function

remove_export(namespace, type)

Removes the saved export based on the namespace and type

Perform one time setup operation for MoSQL to initialize export database and other things

Link to this function

start_full_export(export)

Start the full export process for the given export