Commit Graph

74 Commits

Author SHA1 Message Date
Aravind K P
c8e08e2804 cli: support rest endpoints
GitOrigin-RevId: cd32497fb751489d9b17e91e30e18772f7fa07ec
2021-03-05 03:22:59 +00:00
Aravind K P
8996bcf70d cli: use v2 replace_metadata in config v3
GitOrigin-RevId: b0263799a17052195ebf295516c3105c5c80ce74
2021-02-18 05:37:46 +00:00
Aravind K P
cb029c317b cli: refactor datasource -> database
GitOrigin-RevId: 89bb1fbac0848d833678e33e98b5d558917c13ea
2021-02-17 12:52:37 +00:00
Aravind K P
a0995d1b30 cli: add client package, statestore implementations, deprecate config v1
GitOrigin-RevId: 5a1d9cb772ac62603f2543bfe6c01a95c0a035c6
2021-02-17 04:21:11 +00:00
Aravind K P
8ec92cc198 cli: config v3 project metadata directory
GitOrigin-RevId: c2dce9ca1f37688eecb7eb78c97944ac96d81d54
2021-02-16 06:26:24 +00:00
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