Commit Graph

119 Commits

Author SHA1 Message Date
Aravind K P
3d5b30ce01 cli: fix metadata export behavior of config v2 with a v3 metadata server
GitOrigin-RevId: 76d1d01cee55f950cba3184dd57655c922a8d011
2021-02-15 15:15:44 +00:00
Aleksandra Sikora
b4fd2e3f9f console and cli: run console in CLI mode for tests, misc CLI fixes (#368)
GitOrigin-RevId: 4563444387a4c9d02b5429729fe30bc87763288f
2021-01-20 20:18:44 +00:00
hasura-bot
a398d3b190 cli: support datasources
GITHUB_PR_NUMBER: 6111
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6111

Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 1f6517acfacb58c566bb5e48f74ea0dfa5c6f063
2021-01-18 17:12:09 +00:00
Kali Vara Purushotham Santhati
7cefefabd1 support for set table customization
squash support for set table customization

closes #153

GitOrigin-RevId: c4720e526c6415191c790615144f5de377c635f3
2020-12-28 05:37:36 +00:00
Robert
1477ada1bb cli: update promptui dependency (#51)
* gofmt

* cli: Update promptui to v0.8.0

This is in order to avoid the dependency on the abandoned
kingping.v3-unstable, which was causing dependency conflicts
compiling the pro/cli securelink code.

GitOrigin-RevId: 1264a86ca31b15b2a48c375cd123977084ac558e
2020-11-18 13:36:24 +00:00
Vishnu Bharathi P
58c44f55dd Merge oss/master onto mono/main
GitOrigin-RevId: 1c8c4d60e033c8a0bc8b2beed24c5bceb7d4bcc8
2020-11-12 22:37:19 +05:30
Vishnu Bharathi P
666058ab7f oss: renames dot files and folders
GitOrigin-RevId: 540aeec3be091e1cfb7b05a988f50445534ed663
2020-11-12 22:37:19 +05:30
Aravind K P
01c4cd2ff3
cli: do not clear metadata during metadata apply (close #6115) (#6119)
https://github.com/hasura/graphql-engine/pull/6119
2020-11-06 08:51:10 +00:00
Brian Pedersen
d2d0a05901
cli: fix lint errors in migrate/cmd/commands.go (#5946)
https://github.com/hasura/graphql-engine/pull/5946
2020-10-30 09:12:18 +00:00
Amarnath Karthi
d6d0b99a3c
cli: fix lint errors for /ci/migrate/util.go (#5912)
https://github.com/hasura/graphql-engine/pull/5912
2020-10-29 07:08:12 +00:00
Vladyslav Nekriach
989832cfb5
fix linting in cli/source/stub/stub_test.go (#5972)
https://github.com/hasura/graphql-engine/pull/5972
2020-10-29 05:42:05 +00:00
Sam Radhakrishnan
ee940b4a84
cli: fix linter errors (#5870)
https://github.com/hasura/graphql-engine/pull/5870
2020-10-22 08:08:14 +00:00
Nuno Pato
c348ea7a9d
cli: allow for schema specification when using hasura seeds create (close #5711) (#5710)
https://github.com/hasura/graphql-engine/pull/5710
2020-10-01 13:05:36 +00:00
Sameer Kolhar
963e1106dc
cli: fix error while creating seed file from table names having upper case alphabets (#5549) 2020-08-10 11:28:03 +05:30
Aravind
2592236858
cli: improve error messages for metadata apply (close #5513) (#5548) 2020-08-10 10:54:00 +05:30
Aravind
96f6bdd531
cli: support squashing actions in config v1 (#5249) 2020-07-27 07:15:43 +05:30
Aravind
cd0e2ec8e8
cli: fix permission issues when creating symlinks on windows, misc fix (close #5111, close #4879) (#5164) 2020-07-03 09:49:09 +05:30
Aravind
1aa05624a8
cli: support squashing migrations with cron triggers (squash V1) (#5165) 2020-06-24 19:50:20 +05:30
Aravind
6486a4f0ec
cli: when applying metadata, assume empty metadata plugin files if they don't exist (close #5163) (#5170) 2020-06-24 16:08:48 +05:30
Aravind
1f2037947d
cli: manage seed migrations as sql files (close #2431) (#3763) 2020-06-16 17:45:04 +05:30
Aravind
5a648a9bb2
cli: fix cron triggers not being exported on a metadata export (close #5047) (#5060) 2020-06-16 14:38:36 +05:30
Aravind
d7ca702542
cli: support squashing migrations with remote joins (close #4908) (#4924) 2020-06-16 12:10:20 +05:30
Ashish Rao
d9cc676790
cli: add --dry-run flag to migrate apply command (close #3128) (#3499) 2020-06-03 16:49:36 +05:30
Aravind
daf098886b
cli: fix bug with squashing event triggers (close #4883) (#4949) 2020-06-03 12:13:05 +05:30
Aravind Shankar
16d01bc908
cli: add support for skipping execution while generating migrations through the migrate REST API (#4475) 2020-06-02 10:41:47 +05:30
Shraddha Agrawal
d95d6378e8
cli: add support for servers with self-signed certs (fix #4564) (#4582)
Co-Authored-By: Marion Schleifer <marion@hasura.io>
2020-04-28 17:29:57 +05:30
Aravind Shankar
2ee6328d0d
cli: add check_metadata_consistency for v2 workflow migrations (#4392) 2020-04-22 15:52:02 +05:30
Aravind Shankar
21a4dff993
cli(squash): add set_table_is_enum metadata type (close #4394) (#4395) 2020-04-14 16:39:41 +05:30
Aravind Shankar
53e4f994d2
cli: event trigger retry_conf support to squash (close #4296) (#4324) 2020-04-10 08:22:41 +05:30
Aravind
14b5d10dfb
cli: refactor ec to allow setting hge api headers (#4347) 2020-04-09 15:00:47 +05:30
Aravind Shankar
21b61af109
cli: allow customization of server api paths (close #4016) (#4174) 2020-04-08 16:29:21 +05:30
Aravind Shankar
325771e406
cli: remove migration files if api returns error (close #4312) (#4319)
When using console from CLI and a migration is created, the files are written first and an API call is made to Hasura to execute that migration. There was a bug which caused this file to remain when the API call to Hasura failed. This commit fixes the bug by deleting the files if Hasura API call fails and propagates the error to console.
2020-04-08 10:54:47 +05:30
Aravind
de41438e8a
cli: refactor console command (#4150) 2020-04-07 14:53:20 +05:30
Aravind Shankar
41757b5f7f
cli: fix parse error returned on console api (close #4126) (#4152) 2020-03-25 16:12:39 +05:30
Aravind Shankar
89b6ce86ca
cli: misc fixes related to actions (#3942) 2020-02-25 12:16:11 +05:30
Aravind Shankar
bb63d7e60e
cli: allow managing actions (#3859)
Co-authored-by: Rishichandra Wawhal <rishichandra.wawhal@gmail.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Aravind <aravindkp@outlook.in>
Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2020-02-24 21:44:46 +05:30
Aravind
c258fa75cb
cli: add --goto flag in hasura migrate apply (close #2689) (#3715)
* cli: add --goto <version> flag to migrate command

* cli: fix error encoutered in goto, when on version -1

* do down migrations one step down

* reorganize code

* in case of up "gotos" make sure that all previous migration in migration chain are applied

* modify readUp and readDown functions to account for --goto use case

* refactor to clean up and adopt a better implementation addressing the comments

* remove empty error handling step

* return ErrNoChange when no migrations were applied

* respect m.stop() can panic so place conditional cases after that and add a couple other small fixes

* fix bug caused by early checking of versions

* fix to add migration_mode and nil version check

* add some more examples for migrate apply command

Co-authored-by: Aravind Shankar <face11301@gmail.com>
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2020-02-03 12:33:32 +05:30
Aravind Shankar
bf98f15dcf cli(fix): execute down migration in the correct order (#3625) 2020-01-06 15:21:00 +05:30
Rahul Verma
c6ab1014af cli(fix): better error handling on non-json api responses (clos… (#3104)
Co-authored-by: Rahul Verma <51950008+rahulverma283@users.noreply.github.com>
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2019-12-27 16:28:36 +05:30
Aravind Shankar
337403d532 cli(fix): squash command not adding the last down (close #3401) (#3569)
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2019-12-27 11:35:20 +05:30
Pradeep Murugesan
dece69c5a9 cli: add commands to manage inconsistent metadata (close #2766) (#2973)
Co-authored-by: Aravind Shankar <face11301@gmail.com>
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2019-12-25 14:03:06 +05:30
Rakesh Emmadi
421a182f64 export metadata without nulls, empty arrays & default values (#3393)
* export metadata without nulls, empty arrays
* property tests for 'ReplaceMetadata' using QuickCheck
-> Derive Arbitrary class for 'ReplaceMetadata' dependant types

* reduce property test cases number to 30
QuickCheck generates the `ReplaceMetadata` value really large
for higher number test cases. Encoded JSON for such values is large and
consumes more memory. Thus, CI is giving up while running property
tests.

* circle-ci: Add property tests as saperate job
* add no command mode to tests
* add yaml.v2 to go mod
* remove indirect comment for yaml.v2 dependency
2019-12-14 00:47:38 -06:00
Euler
56a217bbaa add name to migrate status response (close #2376) (#3109) 2019-11-28 17:06:16 +05:30
Aravind Shankar
980c65dbe2 cli(migrations): new folder structure and squash (#3072)
### Description
This PR introduces three new features:

- Support for a new migrations folder structure.
- Add `squash` command in preview.
- ~List of migrations on the Console and ability to squash them from console.~

#### New migrations folder structure

Starting with this commit, Hasura CLI supports a new directory structure for migrations folder and defaults to that for all new migrations created. 

Each migration will get a new directory with the name format `timestamp_name` and inside the directory, there will be four files:

```bash
└── migrations
    ├── 1572237730898_squashed
    │   ├── up.sql
    │   ├── up.yaml
    │   ├── down.yaml
    │   └── down.sql
```

Existing files old migration format `timestamp_name.up|down.yaml|sql` will continue to work alongside new migration files.

#### Squash command

Lots of users have expressed their interest in squashing migrations (see #2724 and #2254) and some even built [their own tools](https://github.com/domasx2/hasura-squasher) to do squash. In this PR, we take a systematic approach to squash migrations.

A new command called `migrate squash` is introduced. Note that this command is in **PREVIEW** and the correctness of squashed migration is not guaranteed (especially for down migrations). From our tests, **it works for most use cases**, but we have found some issues with squashing all the down migrations, partly because the console doesn't generate down migrations for all actions.

Hence, until we add an extensive test suite for squashing, we'll keep the command in preview. We recommend you to confirm the correctness yourself by diffing the SQL and Metadata before and after applying the squashed migrations (we're also thinking about embedding some checks into the command itself).

```bash
$ hasura migrate squash --help
(PREVIEW) Squash multiple migrations leading upto the latest one into a single migration file

Usage:
  hasura migrate squash [flags]

Examples:
  # NOTE: This command is in PREVIEW, correctness is not guaranteed and the usage may change.

  # squash all migrations from version 1572238297262 to the latest one:
  hasura migrate squash --from 1572238297262

Flags:
      --from uint             start squashing form this version
      --name string           name for the new squashed migration (default "squashed")
      --delete-source         delete the source files after squashing without any confirmation
```

### Affected components 
<!-- Remove non-affected components from the list -->

- CLI

### Related Issues
<!-- Please make sure you have an issue associated with this Pull Request -->
<!-- And then add `(close #<issue-no>)` to the pull request title -->
<!-- Add the issue number below (e.g. #234) -->
Close #2724, Close #2254, 

### Solution and Design
<!-- How is this issue solved/fixed? What is the design? -->
<!-- It's better if we elaborate -->

For the squash command, a state machine is implemented to track changes to Hasura metadata. After applying each action on the metadata state, a list of incremental changes is created.

### Steps to test and verify
1. Open console via cli and create some migrations.
2. Run `hasura migrate squash --from <version>`

### Limitations, known bugs & workarounds
<!-- Limitations of the PR, known bugs and suggested workarounds -->

<!-- Feel free to delete these comment lines -->
- The `squash` command is in preview
- Support for squashing from the console is WIP
- Support for squashing migrations that are not committed yet is planned.
- Un-tracking or dropping a table will cause inconsistent squashed down migration since console doesn't generate correct down migration.
- If cascade setting is set to `true` on any of the metadata action, generated migration may be wrong
2019-10-31 07:51:15 +05:30
Aravind Shankar
5f3294f4a0 optimise migrate api for console on cli (#2895) 2019-09-18 11:06:16 +05:30
Aravind Shankar
b39d7b977b check for empty response on migration settings (#2877)
(close #2872) (close #2862)
2019-09-16 14:20:46 +05:30
Aravind Shankar
c17bf2f94b create down migration when a column is dropped (close #2291) (#2385) 2019-06-26 18:42:44 +05:30
Shahidh K Muhammed
71cf017197 add an api to dump postgres schema (close #1939) (#1967) 2019-04-30 14:04:08 +05:30
Aravind Shankar
f147f6d6a6 improve error messages for metadata apply (close #1877) (#1895) 2019-04-03 12:27:59 +05:30
Aravind Shankar
040bef2fd5 add options to create migration from files from sql and server (close #1699) (#1761) 2019-03-18 22:10:04 +05:30
Aravind Shankar
c64a83f073 display error message for invalid migration file (fix #1224) (#1238) 2019-01-04 15:15:54 +05:30
Aravind Shankar
56dbc59822 better error messages for duplicate migration versions (close #1148) (#1157) 2018-12-04 10:03:03 +05:30
Aravind Shankar
6d2fd1db0d added support for file information in hasuradb driver (close #1136) (#1143) 2018-12-03 16:50:53 +05:30
Abilash Menon
0993740786 add reload metadata command to the cli (close #722) (#725) 2018-10-16 11:55:30 +05:30
Daniel P
b91704e3ca fix typos is multiple files (#728) 2018-10-15 12:29:51 +05:30
Aravind Shankar
396a2ccf8d change hasuradb url format, export some migrate functions (#294)
* fix migrate to use headers in query params

* export executeMigrations and PrintStatus
2018-08-22 00:07:47 +05:30
Aravind Shankar
75dbe35a21 create down migrations for actions from console (close #164) (#173) 2018-07-20 16:01:33 +05:30
Aravind Shankar
80c1994dc2 inserts into schema_migration only once per version (fix #127) (#128) 2018-07-12 19:54:46 +05:30
Aravind Shankar
6a20784b95 move metadata.yml file inside migrations folder, fix #122 (#125)
metadata.yaml will be present inside migrations folder
2018-07-12 18:22:25 +05:30
Aravind Shankar
268f0856d0 go vet cli code (#110) 2018-07-11 17:43:31 +05:30
Aravind Shankar
186340c156 fix #96, when access-key is set, cli should use it to contact api (#100) 2018-07-11 14:58:53 +05:30
Aravind Shankar
1bff452cb4 handle server endpoints that contains a url path (#64) 2018-07-09 19:17:38 +05:30
Aravind Shankar
1998e211af cli: update tests (#47)
* remove docker from migrate cmd test

* export migration status

* [cli] add fake writer for spinner

* Update console.go

* Update migrate_test.go
2018-07-06 10:36:27 +05:30
Aravind Shankar
260d565e6e cli: tests for metadata commands (#18)
* [cli] added urlPrefix, consoleMode

* [cli] fix: down=all should throw error if down migration is missing

* [cli] added tests for metadata
2018-06-29 15:32:33 +05:30
Aravind Shankar
59dd23cd17 [migrate status] fix: no migration files message when there are no migration files (#1)
```
$ hasura migrate status
VERSION  SOURCE STATUS  DATABASE STATUS
```
2018-06-28 14:08:47 +05:30
Aravind Shankar
048c067fa1 [cli] add tests for migrate commands (#9) 2018-06-28 14:06:57 +05:30
Shahidh K Muhammed
6d0d75fbe3
[cli] add comments (#4)
Especially for godoc
2018-06-28 14:06:25 +05:30
Shahidh
8e41d75aa3 refactor most of the code 2018-06-26 21:39:32 +05:30
Shahidh
f7409ef2eb
add hasura cli package 2018-06-24 19:10:48 +05:30