All Projects → SeaQL → sea-schema

SeaQL / sea-schema

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
🌿 SQL schema management suite

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to sea-schema

Gnorm
A database-first code generator for any language
Stars: ✭ 415 (+400%)
Mutual labels:  database-schema
Laravel Json Schema
Create all your migrations and models from one JSON schema file.
Stars: ✭ 101 (+21.69%)
Mutual labels:  database-schema
E Commerce Db
Database schema for e-commerce (webstores) sites.
Stars: ✭ 245 (+195.18%)
Mutual labels:  database-schema
Sequel Pro Laravel Export
A Sequel Pro / Sequel Ace bundle to generate Laravel migration files from existing tables.
Stars: ✭ 927 (+1016.87%)
Mutual labels:  database-schema
Sql Database Management System
SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system, or for stream processing in a relational data stream management system.
Stars: ✭ 83 (+0%)
Mutual labels:  database-schema
Real World Grading App
An example of a real-world REST API backend built with TypeScript, Hapi, Prisma, and PostgreSQL.
Stars: ✭ 105 (+26.51%)
Mutual labels:  database-schema
Erd
A Rails engine for drawing your app's ER diagram
Stars: ✭ 296 (+256.63%)
Mutual labels:  database-schema
upscheme
Database migrations and schema updates made easy
Stars: ✭ 737 (+787.95%)
Mutual labels:  database-schema
Dingo
Data access in Go - Code Generator
Stars: ✭ 100 (+20.48%)
Mutual labels:  database-schema
Fluentmigrator
Fluent migrations framework for .NET
Stars: ✭ 2,636 (+3075.9%)
Mutual labels:  database-schema
Mysql Workbench Export Laravel 5 Migrations
A MySQL Workbench plugin which exports a Model to Laravel 5 Migrations
Stars: ✭ 876 (+955.42%)
Mutual labels:  database-schema
Tbls
tbls is a CI-Friendly tool for document a database, written in Go.
Stars: ✭ 940 (+1032.53%)
Mutual labels:  database-schema
Dbmate
🚀 A lightweight, framework-agnostic database migration tool.
Stars: ✭ 2,228 (+2584.34%)
Mutual labels:  database-schema
Migrate
Issues for Prisma Migrate are now tracked at prisma/prisma. This repo was used to track issues for Prisma Migrate Experimental and is now deprecated.
Stars: ✭ 780 (+839.76%)
Mutual labels:  database-schema
introspector
A schema and set of tools for using SQL to query cloud infrastructure.
Stars: ✭ 61 (-26.51%)
Mutual labels:  database-schema
Compalex
Lightweight script to compare two database
Stars: ✭ 318 (+283.13%)
Mutual labels:  database-schema
Postguard
🐛 Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (+25.3%)
Mutual labels:  database-schema
django-yamlfield
A Django database field for storing YAML data
Stars: ✭ 31 (-62.65%)
Mutual labels:  database-schema
django-concurrency-talk
🎭 Database Integrity in Django: Safely Handling Critical Data in Distributed Systems
Stars: ✭ 49 (-40.96%)
Mutual labels:  database-schema
Obevo
Obevo is a database deployment tool that handles enterprise scale schemas and complexity
Stars: ✭ 192 (+131.33%)
Mutual labels:  database-schema

SeaSchema

🌿 SQL schema definition and discovery

crate docs build status

About

SeaSchema is a library to help you manage database schema for MySQL, Postgres and SQLite. It provides 1) type definitions for representing database schema mapping each database closely and 2) utilities to discover them.

GitHub stars If you like what we do, consider starring, commenting, sharing and contributing!

Discord Join our Discord server to chat with others in the SeaQL community!

Architecture

The crate is divided into different modules:

  • def: type definitions
  • query: for querying information_schema
  • parser: for parsing information_schema (parsing sqldump is WIP)
  • writer: for exporting Schema into SeaQuery and SQL
  • discovery: query, parse and construct a Schema

JSON de/serialize on type definitions can be enabled with with-serde.

Schema Discovery

Take the MySQL Sakila Sample Database as example, given the following table:

CREATE TABLE film_actor (
  actor_id SMALLINT UNSIGNED NOT NULL,
  film_id SMALLINT UNSIGNED NOT NULL,
  last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY  (actor_id,film_id),
  KEY idx_fk_film_id (`film_id`),
  CONSTRAINT fk_film_actor_actor FOREIGN KEY (actor_id) REFERENCES actor (actor_id) ON DELETE RESTRICT ON UPDATE CASCADE,
  CONSTRAINT fk_film_actor_film FOREIGN KEY (film_id) REFERENCES film (film_id) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

The discovered schema result:

TableDef {
    info: TableInfo {
        name: "film_actor",
        engine: InnoDb,
        auto_increment: None,
        char_set: Utf8Mb4,
        collation: Utf8Mb40900AiCi,
        comment: "",
    },
    columns: [
        ColumnInfo {
            name: "actor_id",
            col_type: SmallInt(
                NumericAttr {
                    maximum: None,
                    decimal: None,
                    unsigned: Some(
                        true,
                    ),
                    zero_fill: None,
                },
            ),
            null: false,
            key: Primary,
            default: None,
            extra: ColumnExtra {
                auto_increment: false,
                on_update_current_timestamp: false,
                generated: false,
                default_generated: false,
            },
            expression: None,
            comment: "",
        },
        ColumnInfo {
            name: "film_id",
            col_type: SmallInt(
                NumericAttr {
                    maximum: None,
                    decimal: None,
                    unsigned: Some(
                        true,
                    ),
                    zero_fill: None,
                },
            ),
            null: false,
            key: Primary,
            default: None,
            extra: ColumnExtra {
                auto_increment: false,
                on_update_current_timestamp: false,
                generated: false,
                default_generated: false,
            },
            expression: None,
            comment: "",
        },
        ColumnInfo {
            name: "last_update",
            col_type: Timestamp(
                TimeAttr {
                    fractional: None,
                },
            ),
            null: false,
            key: NotKey,
            default: Some(
                ColumnDefault {
                    expr: "CURRENT_TIMESTAMP",
                },
            ),
            extra: ColumnExtra {
                auto_increment: false,
                on_update_current_timestamp: true,
                generated: false,
                default_generated: true,
            },
            expression: None,
            comment: "",
        },
    ],
    indexes: [
        IndexInfo {
            unique: false,
            name: "idx_fk_film_id",
            parts: [
                IndexPart {
                    column: "film_id",
                    order: Ascending,
                    sub_part: None,
                },
            ],
            nullable: false,
            idx_type: BTree,
            comment: "",
            functional: false,
        },
        IndexInfo {
            unique: true,
            name: "PRIMARY",
            parts: [
                IndexPart {
                    column: "actor_id",
                    order: Ascending,
                    sub_part: None,
                },
                IndexPart {
                    column: "film_id",
                    order: Ascending,
                    sub_part: None,
                },
            ],
            nullable: false,
            idx_type: BTree,
            comment: "",
            functional: false,
        },
    ],
    foreign_keys: [
        ForeignKeyInfo {
            name: "fk_film_actor_actor",
            columns: [
                "actor_id",
            ],
            referenced_table: "actor",
            referenced_columns: [
                "actor_id",
            ],
            on_update: Cascade,
            on_delete: Restrict,
        },
        ForeignKeyInfo {
            name: "fk_film_actor_film",
            columns: [
                "film_id",
            ],
            referenced_table: "film",
            referenced_columns: [
                "film_id",
            ],
            on_update: Cascade,
            on_delete: Restrict,
        },
    ],
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

SeaSchema is a community driven project. We welcome you to participate, contribute and together build for Rust's future.

A big shout out to our contributors:

Contributors

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].