All Projects â†’ daichirata â†’ hammer

daichirata / hammer

Licence: MIT License
🛠 hammer is a command-line tool to schema management for Google Cloud Spanner.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to hammer

Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+5992.11%)
Mutual labels:  spanner, google-cloud-spanner
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+20194.74%)
Mutual labels:  spanner, google-cloud-spanner
ecto generator
Generate Ecto schemas from existing database in Phoenix - Elixir
Stars: ✭ 20 (-47.37%)
Mutual labels:  schema
fefe
Validate, sanitize and transform values with proper TypeScript types and zero dependencies.
Stars: ✭ 34 (-10.53%)
Mutual labels:  schema
spanner-schema-diff-tool
Compare two Cloud Spanner Schema (DDL) files, determine the differences and generate the required ALTER statements to convert one schema to the other.
Stars: ✭ 20 (-47.37%)
Mutual labels:  google-cloud-spanner
thema
A CUE-based framework for portable, evolvable schema
Stars: ✭ 41 (+7.89%)
Mutual labels:  schema
the schema is
ActiveRecord schema annotations done right
Stars: ✭ 44 (+15.79%)
Mutual labels:  schema
tyshemo
A javascript runtime data type checking system and morden reactive state management model.
Stars: ✭ 70 (+84.21%)
Mutual labels:  schema
DataAnalyzer.app
✨🚀 DataAnalyzer.app - Convert JSON/CSV to Typed Data Interfaces - Automatically!
Stars: ✭ 23 (-39.47%)
Mutual labels:  schema
bluepine
A DSL for defining API schemas/endpoints, validating, serializing and generating Open API v3
Stars: ✭ 21 (-44.74%)
Mutual labels:  schema
graphql-tutorial
Tutorial for GraphQL
Stars: ✭ 24 (-36.84%)
Mutual labels:  schema
haskell-schema
A library for describing Haskell data types and obtain free generators, JSON codecs, pretty printers, etc.
Stars: ✭ 16 (-57.89%)
Mutual labels:  schema
flycouchdb
Migration tool for CouchDB
Stars: ✭ 20 (-47.37%)
Mutual labels:  schema
gql
This is a GraphQL server written in Go
Stars: ✭ 31 (-18.42%)
Mutual labels:  schema
linkedin-to-jsonresume
Browser extension to turn a LinkedIn profile page into a JSON Resume export.
Stars: ✭ 93 (+144.74%)
Mutual labels:  schema
domain-schema
Domain Driven Design Schema for JavaScript
Stars: ✭ 22 (-42.11%)
Mutual labels:  schema
openapi-schema-validator
OpenAPI schema validator for Python
Stars: ✭ 35 (-7.89%)
Mutual labels:  schema
craftql
A CLI tool to visualize GraphQL schemas and to output a graph data structure as a graphviz .dot format
Stars: ✭ 75 (+97.37%)
Mutual labels:  schema
data-models
Collection of various biomedical data models in parseable formats.
Stars: ✭ 23 (-39.47%)
Mutual labels:  schema
fform
Flexibile and extendable form builder with constructor
Stars: ✭ 26 (-31.58%)
Mutual labels:  schema

hammer

hammer is a command-line tool to schema management for Google Cloud Spanner.

Installation

Download the single-binary executable from:

https://github.com/daichirata/hammer/releases

or

$ go get -u github.com/daichirata/hammer

Usage

$ hammer -h
hammer is a command-line tool to schema management for Google Cloud Spanner.

Usage:
  hammer [command]

Examples:

* Export spanner schema
  hammer export spanner://projects/projectId/instances/instanceId/databases/databaseName > schema.sql

* Apply local schema file
  hammer apply spanner://projects/projectId/instances/instanceId/databases/databaseName /path/to/file

* Create database and apply local schema (faster than running database creation and schema apply separately)
  hammer create spanner://projects/projectId/instances/instanceId/databases/databaseName /path/to/file

* Copy database
  hammer create spanner://projects/projectId/instances/instanceId/databases/databaseName1 spanner://projects/projectId/instances/instanceId/databases/databaseName2

* Compare local files
  hammer diff /path/to/file /another/path/to/file

* Compare local file against spanner schema
  hammer diff /path/to/file spanner://projects/projectId/instances/instanceId/databases/databaseName

* Compare spanner schema against spanner schema
  hammer diff spanner://projects/projectId/instances/instanceId/databases/databaseName1 spanner://projects/projectId/instances/instanceId/databases/databaseName2

Available Commands:
  apply       Apply schema
  create      Create database and apply schema
  diff        Diff schema
  export      Export schema
  help        Help about any command

Flags:
  -h, --help   help for hammer

Use "hammer [command] --help" for more information about a command.

The DSN must be given in the following format.

spanner://projects/{projectId}/instances/{instanceId}/databases/{databaseName}?credentials=/path/to/file.json
Param Required Description
projectId true The Google Cloud Platform project id
instanceId true The id of the instance running Spanner
databaseName true The name of the Spanner database
credentials false The path to the keyfile. If not present, client will use your default application credentials.

Examples

Suppose you have an existing SQL schema like the following:

CREATE TABLE users (
  user_id STRING(36) NOT NULL,
) PRIMARY KEY(user_id);

And you want "upgrade" your schema to the following:

CREATE TABLE users (
  user_id STRING(36) NOT NULL,
  age INT64,
  name STRING(MAX) NOT NULL,
) PRIMARY KEY(user_id);
CREATE INDEX idx_users_name ON users (name);

Hammer changes the schema by applying the following SQL to the spanner:

hammer diff old.sql new.sql

ALTER TABLE users ADD COLUMN age INT64
ALTER TABLE users ADD COLUMN name STRING(MAX)
UPDATE users SET name = '' WHERE name IS NULL
ALTER TABLE users ALTER COLUMN name STRING(MAX) NOT NULL
CREATE INDEX idx_users_name ON users(name)

When adding a column with the NOT NULL attribute, update the default value after adding the column once, and then add the NOT NULL attribute.

LICENSE

Unless otherwise noted, the hammer source files are distributed under the MIT License found in the LICENSE file.

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