Commit Graph

103 Commits

Author SHA1 Message Date
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
Sameer Kolhar
13e4edbdf8
cli: add flags --up-sql and --down-sql to migrate create command (close #5026) (#5039) 2020-06-16 11:30: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
177556f441
cli: fix tests failing in local dev environment (#4729) 2020-06-03 14:01:40 +05:30
Aravind
edbd9c4f48
cli: load assets from server if cdn is disabled (close #3382) (#3851) 2020-06-03 09:36:23 +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
scriptonist
b771956336 cli: fix update scripts failing when sql migrations files are already present 2020-05-26 08:46:36 +05:30
Aravind
f1c3b43f6f
cli: fix docs failing to build (close #4637) (#4698) 2020-05-07 13:03:50 +05:30
Can Taşpınar
9d815598cc
cli: include new commands in help text (fix #4623) (#4626) 2020-05-05 09:21:20 +05:30
Shraddha Agrawal
88685736c7
Merge branch 'master' into init-current-directory 2020-04-28 18:35:00 +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
Shraddha Agrawal
f7b99b53e4 minor fixes 2020-04-27 13:26:34 +05:30
Shraddha Agrawal
d5ae48c14e update help text and docs for init command 2020-04-27 10:03:10 +05:30
Shraddha Agrawal
e9cad694ed validate pwd is neither filesystem root nor an existing hasura project 2020-04-27 09:04:32 +05:30
Shraddha Agrawal
3053af1055 cli: allow initialising project in current directory 2020-04-26 22:24:48 +05:30
Shraddha Agrawal
38529b3960
cli: remove irrelevant flags from init command (close #4508) (#4549) 2020-04-25 11:33:13 +05:30
Shraddha Agrawal
e07761eb33
cli: validate endpoint using ParseRequestURI (fix #4407) (#4416) 2020-04-23 08:40:24 +05:30
Shraddha Agrawal
75d35ac2f6
cli: add suport for .env file (fix #4129) (#4454) 2020-04-23 08:17:51 +05:30
Aravind Shankar
aca11f0944
cli: spinner bug, add cli_environment in global config (#4459)
close #4456
close #4436
close #4496
2020-04-22 14:45:42 +05:30
Rishichandra Wawhal
8a5cc73ae6
cli, console: actions dx improvements (close #4306, #4311) (#4308) 2020-04-16 13:40:47 +05:30
Aravind Shankar
491a50b1e9
cli: link cli-ext plugin with cli version (close #4105) (#4280) 2020-04-13 08:46:06 +05:30
Aravind
14b5d10dfb
cli: refactor ec to allow setting hge api headers (#4347) 2020-04-09 15:00:47 +05:30
Aravind
e1b0562fd8
cli: clarify flags on migrate create (#4316) 2020-04-09 14:35:05 +05:30
Aravind Shankar
995e198d0a
cli: show env vars for the flags in command help (close #4263) (#4326) 2020-04-08 17:25:42 +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
d5e61716f8
cli: add support for multiple versions of plugin (close #4105) (#4135) 2020-04-07 19:42:14 +05:30
Aravind
de41438e8a
cli: refactor console command (#4150) 2020-04-07 14:53:20 +05:30
Aravind Shankar
09e0e2f2a5
cli: fix init command to generate correct config (fix #4036) (#4038) 2020-03-26 08:54:05 +05:30
Aravind Shankar
13e8a3c010
cli: send command path in telemetry data (#4095) 2020-03-26 08:38:54 +05:30
Dmitry Minkovsky
b6780e8a15
cli: fix typo in cli example for squash (fix #4047) (#4049) 2020-03-09 15:19:00 +05:30
Shahidh K Muhammed
d7d53f222c
cli: add version flag in update-cli command (#3996)
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2020-03-05 12:25:33 +05:30
Aravind Shankar
e3b843ce81
cli: fix flags in actions, migrate and metadata cmd (fix #3982) (#3991) 2020-03-03 12:36:59 +05:30
Praveen Durairaju
865b150c82
noop: replace subdomain links with subpath (#3869)
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
2020-02-27 15:43:07 +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
Shahidh K Muhammed
f6a43fe3ba
fix various version-related issues with cli (close #3706) (#3709)
- do not quit on server-cli version mismatch, show warning
- fix a bug in update-cli command which prevets updates to pre-release
versions
- if a console template for a particular version is not found, use the
latest template
2020-01-16 09:23:18 +05:30
Ashish Rao
2fc49eaa63 cli: add browser flag to console command (close #3333) (#3601)
Co-authored-by: Ashish Rao <ashishrao@hasura.io>
Co-authored-by: Thibaut Tiberghien <thibaut@smplrspace.com>
2020-01-08 08:36:09 +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
Shahidh K Muhammed
8ea6f77c7b
cli: add directory name as an argument to init cmd (#3590)
* add directory-name as an argument to init command

* change dev version to a const string
2019-12-25 14:01:29 +05:30
Alexis King
bdf79dfc48
Fix failing CLI test (#3567) 2019-12-18 16:45:29 -06:00
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
Ashish Rao
b183eba9ba add examples to all cli commands (#3475) (#3492) 2019-12-12 10:46:36 +05:30
Ashish Rao
094bbc8760 fix(cli): mark from flag as required for squash (close #3400) (#3500) 2019-12-10 15:48:58 +05:30
Euler
56a217bbaa add name to migrate status response (close #2376) (#3109) 2019-11-28 17:06:16 +05:30
Rakesh Emmadi
9b8e6b42d1 functions can access session info via input arg (close #2322) (#3143) 2019-11-20 12:17:06 +05:30
Rakesh Emmadi
3888ceb24a computed fields in export/import metadata, other fixes (#3211) 2019-11-07 20:09:48 +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
Jeff Sieu
2ee7f7d76e cli(metadata): add diff command and dry-run flag (#3157)
### Description
Adds a `metadata diff` command to show comparisons between two different sets of Hasura metadata.
```
# Show changes between server metadata and the exported metadata file:
hasura metadata diff

# Show changes between server metadata and that in local_metadata.yaml:
hasura metadata diff local_metadata.yaml

# Show changes between metadata from metadata.yaml and metadata_old.yaml:
hasura metadata diff metadata.yaml metadata_old.yaml
```

Also adds a `--dry-run` flag to `metadata apply` command which will print the diff and exit rather than actually applying the metadata.

### Affected components 
- CLI
- Docs

### Related Issues
Close #3126, Close #3127

### Solution and Design
- Added `metadata_diff.go` and `metadata_diff_test.go`


### Steps to test and verify
```
hasura metadata export
# Make changes to migrations/metadata.yaml
hasura metadata diff
```

### Limitations, known bugs & workarounds
This is just a general-purpose diff. 

A more contextual diff with the understanding of metadata can be added once #3072  is merged.
2019-10-30 19:24:22 +05:30