Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mfridman/remigrate
A tool for creating a database, tables and secondary indexes in rethinkDB from a file
https://github.com/mfridman/remigrate
go golang rethinkdb
Last synced: about 1 month ago
JSON representation
A tool for creating a database, tables and secondary indexes in rethinkDB from a file
- Host: GitHub
- URL: https://github.com/mfridman/remigrate
- Owner: mfridman
- License: mit
- Created: 2018-03-16T21:17:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-16T21:31:44.000Z (almost 7 years ago)
- Last Synced: 2024-10-14T06:09:19.717Z (3 months ago)
- Topics: go, golang, rethinkdb
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
`remigrate` is a tool for creating a database, tables and secondary indexes in rethinkDB.
More info on the database can be found here: [RethinkDB](https://www.rethinkdb.com/docs) and the underlying driver can be found here: [gorethink](https://github.com/GoRethink/gorethink)
## Installation
go get -u github.com/mfridman/remigrate
## Usage
`remigrate` reads from a file named config (by default) in the same directory or an absolute path specified with the `--config` flag. File format must be YAML, the extension .yml or .yaml can be omitted.
remigrate --config /etc/configs/rethinkdb_up.yml
A sample YAML file, config, is included in the Git repo.
__Note__, only simple indexes are supported for now. If you need geospatial index file an issue.
```yaml
# mandatory options
ip: localhost
port: 28015 # this is the default rethinkdb port
database_name: machinestables:
- name: robots # mandatory
primary_key: serial_num # can be omitted, defaults to id
simple_index: [version, model] # can be omitted
- name: parts # mandatory
```Output:
```shell
[machines ] create database
[robots ] create table
[version ] create secondary index on robots
[model ] create secondary index on robots
[parts ] create table
---
1 database created
2 table(s) created
2 secondary index(es) created
```Running the above will create a machines database, with 2 tables: robots and features. The robots table primary key is serial_num and secondary indexes are version and model.
You can read more here: [Using secondary indexes in RethinkDB](https://www.rethinkdb.com/docs/secondary-indexes)
Re-running the above file is safe, i.e., existing items are ignored:
```shell
[machines ] ignore database exists
[robots ] ignore table exists
[version ] ignore secondary index exists on robots
[model ] ignore secondary index exists on robots
[parts ] ignore table exists
---
0 database created
0 table(s) created
0 secondary index(es) created
```The table info for the above example in rethinkdb would be:
robots:
```json
{"db": {
"id": "7277457e-b653-436f-be02-040cb230e414" ,
"name": "machines" ,
"type": "DB"
} ,
"doc_count_estimates": [
18734
] ,
"id": "a42215be-f7b2-42e6-8bd7-d60d20a35afa" ,
"indexes": [
"model" ,
"version"
] ,
"name": "robots" ,
"primary_key": "serial_num" ,
"type": "TABLE"}
```parts:
```json
{"db": {
"id": "7277457e-b653-436f-be02-040cb230e414" ,
"name": "machines" ,
"type": "DB"
} ,
"doc_count_estimates": [
0
] ,
"id": "1bdbb34b-631e-478a-bb2b-4bd35633864e" ,
"indexes": [ ],
"name": "parts" ,
"primary_key": "id" ,
"type": "TABLE"}
```## Caution!!
There is a `--dbdrop` flag, running it will ask for a confirmation:
are you sure you want to drop the [machines] database [y/n]:
n:
```shell
exiting without dropping database [machines]
```y:
```shell
1 database dropped
2 table(s) dropped
```