Commit Graph

37 Commits

Author SHA1 Message Date
Mohd Bilal
8cee3c53b9 cli: Use - instead of * in unordered list in docs and fix char cases
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7492
GitOrigin-RevId: 5b76d0a970193da4412ff1b595caec23996f265c
2023-01-11 08:39:18 +00:00
Rikin Kachhia
50a5462857 cli: improve log messages to highlight database names
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7363
GitOrigin-RevId: 2b58511c374ee4d93a202e23c87c48b54ec363a6
2023-01-09 08:03:13 +00:00
Rob Dominguez
1128753069 docs: add links to feature docs for CLI commands
[DOCS-520]: https://hasurahq.atlassian.net/browse/DOCS-520?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[DOCS-520]: https://hasurahq.atlassian.net/browse/DOCS-520?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7419
GitOrigin-RevId: 52e8e54bf7068ee91fce19831db99d7a24afb00c
2023-01-09 04:27:34 +00:00
Rob Dominguez
880182c805 docs: improve Long values for CLI
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7399
GitOrigin-RevId: 6e848f6eae2e5418c386f814623c122646db12c7
2022-12-30 03:52:33 +00:00
Aravind K P
061f6b96ed cli: port migrate, migrate status to use internal/errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6547
GitOrigin-RevId: edef43331e06b227484e84a39f4b81b5fdaf1658
2022-11-03 05:56:00 +00:00
Kali Vara Purushotham Santhati
f0bef2b482 cli: add All option for migrate sub-commands (apply, delete and status) and seed apply command
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2509
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 03ee878072b58c6dc7f43af9d26d30a5594d9a50
2021-12-23 15:59:56 +00:00
Kali Vara Purushotham Santhati
94a3be3e6e cli: fix lint errors
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/1749
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 4515f7f2c58b7f28645b2c5a5d9842aa7a844eae
2021-10-13 14:39:15 +00:00
Kali Vara Purushotham Santhati
bcb0b99f8b cli: make --database-name optional in migrate subcommands when using a single database
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2428
GitOrigin-RevId: 2319408773b1c73bca6297c7b22dc3db82775953
2021-10-08 13:30:12 +00:00
Kali Vara Purushotham Santhati
fbbd423d8b cli: migrate create gives warning if database isn't connected to server
https://github.com/hasura/graphql-engine-mono/pull/1518

Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: a9e836545922719bcbd6e8c9c027df6056d23cef
2021-06-21 13:55:09 +00:00
Aravind K P
3136ffad1b cli: update go.mod
>

### Description
Update `go.mod` to allow other packages to import [v2.0.0 versions](https://blog.golang.org/v2-go-modules).

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] CLI

https://github.com/hasura/graphql-engine-mono/pull/1584

GitOrigin-RevId: a5d17ad20289d1cd7217763f56ef3ba6552d69c4
2021-06-16 11:45:07 +00:00
Vishnu Bharathi
4b76289d03 cli: add interactive prompt to get input when --database-name flag is missing
GitOrigin-RevId: f92478d0ca6a4f6d0cfaa7aca3b4bb8a215a5cad
2021-06-09 07:13:46 +00:00
Kali Vara Purushotham Santhati
5e92ce028e cli: migrate delete command, update migration state on server after squash
It contains 2 flags

all   -  To delete all migrations locally and on database
version - To delete a single migration locally and on database

Usage :
`hasura migrate delete --all`
`hasura migrate delete --version <version_number>`

Additional fix :
The `migrate squash`  will deletes the migration history on server after squashing if user opts to delete the migrations.

closes https://github.com/hasura/graphql-engine-mono/issues/292
closes https://github.com/hasura/graphql-engine/issues/5373
closes https://github.com/hasura/graphql-engine/issues/6434

Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: fa7ceae7a1970d6724fb601a147900e880ad2e6f
2021-05-24 02:34:33 +00:00
Aravind K P
9dfed5da57 cli: fix applying migrations in a different environment after config v3 update
GitOrigin-RevId: 2f5d554dba50da1d45ea9689afca07f4d0f2c1e5
2021-05-17 15:20:08 +00:00
Aravind K P
7638d1832a cli: add support for bigquery
GitOrigin-RevId: 8d479cbd056ee839b11ae24557085573b3e5b5ba
2021-04-19 07:06:18 +00:00
Aravind K P
7f420ad1ae cli: add --all--databases flag on migrate apply
GitOrigin-RevId: 87a8b4250abad349153d1af73917859bd8f2a31a
2021-04-01 12:59:20 +00:00
Kali Vara Purushotham Santhati
c3e60aba28 cli: update cli help texts and docs generation
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: b6909583093baac4a69296721feae149ca6a0605
2021-03-15 15:41:54 +00:00
Aravind K P
ae92ac4941 cli: rename flag --database to --database-name
GitOrigin-RevId: 37fb8dd4f82c2b68f87013e5ec87d5b2dab8853f
2021-03-09 06:44:37 +00:00
Aravind K P
f6ca551df4 cli: support mssql sources
GitOrigin-RevId: 4b1a63c8dc342ae4001b16c4b1dce282092d5c6f
2021-03-08 12:00:34 +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
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
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
995e198d0a
cli: show env vars for the flags in command help (close #4263) (#4326) 2020-04-08 17:25:42 +05:30
Aravind
de41438e8a
cli: refactor console command (#4150) 2020-04-07 14:53:20 +05:30
Aravind Shankar
13e8a3c010
cli: send command path in telemetry data (#4095) 2020-03-26 08:38:54 +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
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
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
nizar-m
f83a8e591f rename access-key to admin-secret (close #1347) (#1540)
Rename the admin secret key header used to access GraphQL engine from X-Hasura-Access-Key to X-Hasura-Admin-Secret.

Server CLI and console all support the older flag but marks it as deprecated.
2019-02-14 15:07:47 +05:30
Shahidh K Muhammed
330f90de40
add project flag, change persistentprerun to prerun (close #552) (#557)
### Description

Adds `--project` flag to the CLI and changes all `PersistentPreRuns` to `PreRuns`

What component does this PR affect? 

- [ ] Server
- [ ] Console
- [x] CLI
- [ ] Docs
- [ ] Community Content
- [ ] Build System

### Related Issue

#552
2018-09-27 19:27:17 +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
1bff452cb4 handle server endpoints that contains a url path (#64) 2018-07-09 19:17:38 +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