Giter VIP home page Giter VIP logo

database-schema-operator's Introduction

Database Migration Schema Operator

This is a DBaaC (Database as a Code) using Kubernetes Operator pattern.

There will be some CRDs

  • Database
  • Table

Roadmap

  • check if table exists
  • create table with defined columns
  • alter existing columns
  • add new columns
  • remove old columns (is it safe?)
  • use connection parameters from Database
  • refator everything :-)

Sample Database:

apiVersion: db.pedag.io/v1
kind: Database
metadata:
  name: adventureworks
spec:
  name: AdventureWorks
  server: localhost
  port: 1433
  user: sa
  password: itssecret

Sample Table:

apiVersion: db.pedag.io/v1
kind: Table
metadata:
  name: users-table
spec:
  name: Users
  databaseRef:
    name: adventureworks
    kind: Database
  columns:
  - name: Id
    type: int not null identity(1,1)
  - name: Name
    type: varchar(50) not null
  - name: Email
    type: varchar(255) not null
  - name: Active
    type: bit not null default(0)
  - name: Blocked
    type: bit not null default(0)

Every Table must have a Database reference.

Database will be something like SQLDatabase, PostgresDatabase, MySQLDatabase, etc.

Not sure if we will use any orm (like xorm.io) or pure SQL.

Controller logs:

2020-08-06T15:48:53.625-0300	INFO	controller-runtime.metrics	metrics server is starting to listen	{"addr": ":8080"}
2020-08-06T15:48:53.626-0300	INFO	setup	starting manager
2020-08-06T15:48:53.626-0300	INFO	controller-runtime.manager	starting metrics server	{"path": "/metrics"}
2020-08-06T15:48:53.626-0300	INFO	controller-runtime.controller	Starting EventSource	{"controller": "table", "source": "kind source: /, Kind="}
2020-08-06T15:48:53.626-0300	INFO	controller-runtime.controller	Starting EventSource	{"controller": "database", "source": "kind source: /, Kind="}
2020-08-06T15:48:53.727-0300	INFO	controller-runtime.controller	Starting Controller	{"controller": "database"}
2020-08-06T15:48:53.727-0300	INFO	controller-runtime.controller	Starting workers	{"controller": "database", "worker count": 1}
2020-08-06T15:48:53.727-0300	INFO	controller-runtime.controller	Starting Controller	{"controller": "table"}
2020-08-06T15:48:53.727-0300	INFO	controller-runtime.controller	Starting workers	{"controller": "table", "worker count": 1}
2020-08-06T15:48:53.739-0300	DEBUG	controller-runtime.controller	Successfully Reconciled	{"controller": "database", "request": "default/adventureworks"}
2020-08-06T15:48:53.781-0300	INFO	controllers.Table	Creating table [Addresses] on database.	{"table": "default/addresses-table"}
2020/08/06 15:48:53 create table [Addresses] ([Street] varchar(50),[Number] varchar(50),[UserId] int,)
2020-08-06T15:48:53.810-0300	DEBUG	controller-runtime.controller	Successfully Reconciled	{"controller": "table", "request": "default/addresses-table"}
2020-08-06T15:48:53.853-0300	INFO	controllers.Table	Creating table [Users] on database.	{"table": "default/users-table"}
2020/08/06 15:48:53 create table [Users] ([Id] int not null identity(1,1),[Name] varchar(50) not null,[Email] varchar(255) not null,[Active] bit not null default(0),[Blocked] bit not null default(0),)
2020-08-06T15:48:53.876-0300	DEBUG	controller-runtime.controller	Successfully Reconciled	{"controller": "table", "request": "default/users-table"}

database-schema-operator's People

Contributors

edernucci avatar sleipnir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sleipnir

database-schema-operator's Issues

Support to create system_versioning tables in MariaDB

It would be interesting to support the creation of tables of type SYSTEM_VERSIONING including the declaration of partitions.
Perhaps this issue should be broken down into more issues as just creating partitions would require a series of parallel works.
Here is an example of create table SYSTEM_VERSIONING on mariadb:

CREATE TABLE IF NOT EXISTS _operator_.tag_sequence_events (
    toll_company_id     numeric(10)  NOT NULL,
    operator_id         numeric(10)  NOT NULL,
    series              numeric(10)  NOT NULL,
    sequence_id         numeric(19)  NOT NULL,
    event_id            varchar(36)  NOT NULL,
    event_timestamp     varchar(24)  NOT NULL,
    event_source_type   varchar(20)  NOT NULL,
    event_status        varchar(20)  NOT NULL,
    headers             JSON,
        CHECK (headers IS NULL OR JSON_VALID(headers)),
    content_raw         BLOB,
    content_serialized  BLOB,
    PRIMARY KEY (
        toll_company_id,
        operator_id,
        series,
        sequence_id
    )
)
WITH SYSTEM VERSIONING
	PARTITION BY SYSTEM_TIME LIMIT 100000 (
	PARTITION hist_0 HISTORY,
	PARTITION hist_1 HISTORY,
	PARTITION current CURRENT
);

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.