Commit Graph

1255 Commits

Author SHA1 Message Date
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
Alexis King
d6a649095c
Build server in CI with optimizations, even in pull requests (#3240) 2019-10-30 11:07:57 -05:00
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
Bharath Shendre
ed093cdc7e update event-triggers.md (#2989) 2019-10-30 08:21:42 +05:30
Shahidh K Muhammed
a9107a2fc3 console (make): fix gcs bucket name (close #3026) (#3260) 2019-10-28 12:15:16 +05:30
Rikin Kachhia
fcf03919de
add docs page for setting up unauthenticated acess (#3231) 2019-10-28 11:46:25 +05:30
Shahidh K Muhammed
ba751450be change pg_dump version to 12 in server makefile (#3249) 2019-10-26 12:03:54 -05:00
Shahidh K Muhammed
31e0225230
add tests with postgres 12 (close #2749) (#3102) 2019-10-26 11:09:57 +05:30
Rakesh Emmadi
6daa1bb330 update pr template with server breaking changes checklist (#2932) 2019-10-26 09:54:20 +05:30
Akshit Sarin
0b99930a7b Fix typo in CONTRIBUTING.md file (#3043) 2019-10-26 09:52:44 +05:30
Sameer Tulshyan
e09826b23a community(sample-apps): mod firebase-jwt html (#3044) 2019-10-26 09:51:55 +05:30
Low Jeng Lam
3b3e79b1cd fixed typo 'SCHEMA' (#3054) 2019-10-26 09:45:57 +05:30
Shivam175
aa6947a608 fix grammar in docs (#3065) 2019-10-26 09:43:38 +05:30
LOLDeveloper
251f861787 fixed some grammer mistakes in docs (#3027) 2019-10-26 09:37:37 +05:30
OrginalS
2fbb6238e0 typo fix in readme (#3039) 2019-10-26 09:36:35 +05:30
Marion Schleifer
c872d21619 Add AWS Cognito JWT links to docs (#2910) 2019-10-26 09:35:58 +05:30
Rishichandra Wawhal
9d2ce81c70 move community tools to separate repos (#3155) 2019-10-26 09:32:32 +05:30
Marion Schleifer
7664f1a528 add production checklist to docs (close #2561) (#3140) 2019-10-23 14:53:41 +05:30
Shahidh K Muhammed
713d689dc1 update manifests to v1.0.0-beta.8 2019-10-22 12:54:35 +05:30
Rikin Kachhia
a8fe0b6619
fix computed fields variable name in console (#3196) 2019-10-22 11:33:06 +05:30
Rikin Kachhia
8000652a5d
fix console test environment (#3192) 2019-10-22 11:28:35 +05:30
Rakesh Emmadi
6d92e4f9db save permissions, relationships and collections in catalog with 'is_system_defined' explicitly (#3165)
* save permissions, relationships and collections in catalog with 'is_system_defined'
* Use common stanzas in the .cabal file
* Refactor migration code into lib instead of exe
* Add new server test suite that exercises migrations
* Make graphql-engine clean succeed even if the schema does not exist
2019-10-21 11:01:05 -05:00
Grzegorz Wcisło
7b59f5dc2e Add ruby examples for triggers on lambda (address #1740) (#3007) 2019-10-21 17:04:22 +05:30
MIP2000
c5c314af81 Add Greek translation of README.md (#3123) 2019-10-21 16:24:51 +05:30
Rikin Kachhia
68a724f3c7
put computed fields console changes behind version check (#3190) 2019-10-21 13:07:29 +05:30
nizar-m
842913f566 Add tests for directives skip and include and basic tests for fragments (fix #3180) (#3185)
* Add tests for directives include and skip
* Add basic tests for fragments
2019-10-20 06:59:41 -05:00
Rishichandra Wawhal
d14300e9c9 generate migrations for replace metadata (close #2996) (#2999) 2019-10-18 18:53:55 +05:30
Rakesh Emmadi
d8d21c1487 support computed fields returning scalars or set of tables (close #1387) (#2917) 2019-10-18 13:59:47 +05:30
Rishichandra Wawhal
d82c6d464f fix telemetry notification display (#3166) 2019-10-17 18:18:28 +05:30
Rikin Kachhia
1369876699
Revert "update manifests to v1.0.0-beta.8" (#3167) 2019-10-17 17:48:29 +05:30
Marion Schleifer
068d037efd add catalogue version downgrade instructions to docs (close #2620) (#2819) 2019-10-17 17:32:01 +05:30
Shahidh K Muhammed
7c1a964819 update manifests to v1.0.0-beta.8 2019-10-17 15:30:07 +05:30
Shahidh K Muhammed
b7fb4eb13e
cli-migrations: enable metadata api while applying migrations (#3163) 2019-10-17 15:28:27 +05:30
Rishichandra Wawhal
2e93abd6a9 display table check constraints in console (close #2898) (#3086) 2019-10-16 21:24:27 +05:30
Alexis King
e01008413e
Track variable uses within query validation for caching (fix #3097) (#3135)
This fix is a little ugly, but it’s the only simple solution without a
significant refactoring that restructures the relationship between
GraphQL/Validate and GraphQL/Resolve. The ugliness should go away if we
implement something like #2801.
2019-10-16 09:33:34 -05:00
Rishichandra Wawhal
86ab64232d fix setting new role name when perm edit is open (closes #2682) (#2997) 2019-10-15 18:49:23 +05:30
Rikin Kachhia
61d6610ed6
fix console row edit behaviour (close #3121) (#3133)
* handle unmodified fields
* handle setting default value
2019-10-15 15:13:10 +05:30
Rishichandra Wawhal
81de56dc70 community: tic-tac-toe: fix names bug and add docker-compose (#3058) 2019-10-11 16:27:55 +05:30
Shahidh K Muhammed
624ce0c6aa Revert "update manifests to v1.0.0-beta.7"
This reverts commit ae145c587f.
2019-10-11 11:14:25 +05:30
Ajeet D'Souza
a66fb42ce2 Make catalog metadata migrations work on all schema versions (fix #2826) (#2379)
* Separate DB and metadata migrations
* Refactor Migrate.hs to generate list of migrations at compile-time
* Replace ginger with shakespeare to improve performance
* Improve migration log messages
2019-10-11 00:13:57 -05:00
Alexis King
c0d7402e15
Fix two enum table reference bugs (fix #2820 and #3010) (#3074)
* Include enum types in schema whenever references are visible (fix #2820)
* Fix RQL parsing for nullable enum table references (fix #3010)
2019-10-10 21:22:16 -05:00
craigglennie
ddf5997eac ra-data-hasura: update readme explain some imports (close #2905) (#2906)
I was a little confused about where some of the imports in the example code came from, until I realised that they're created as part of the react-admin tutorial. I added a comment explaining that.
2019-10-10 21:39:50 +05:30
Oleg Butuzov
2e9d9bc621 update broken links in docs (#3055)
* Removed text about source code

Source code was removed by hasura/graphql-engine@fb3794c3

* links update for subscriptions/index

links updated because
1) facebook.github.io was changed to graphql.github.io/graphql-spec/
2) path to docs changed by apollographql/apollo-client@41ca8ff1
2019-10-10 21:28:24 +05:30
Rakesh Emmadi
b0d60ec14f fix hdb_catalog.hdb_column view (fix #3083) (#3084) 2019-10-10 10:11:17 -05:00
Shahidh K Muhammed
3f088cd7ac
remove generic rule from codeowners 2019-10-10 20:15:13 +05:30
Alexis King
3ef6feb394
server: Fix flaky logging test (#3081)
The changes in 0c74839934 adjusted the
format of error logs slightly to omit fields instead of including them
with null values. However, this was rarely triggered by this test
because it only looks at the first log message, but log messages can
sometimes be written out of order. This makes the test order-agnostic.
2019-10-10 08:40:19 -05:00
Shahidh K Muhammed
ae145c587f update manifests to v1.0.0-beta.7 2019-10-10 10:37:33 +05:30
Rikin Kachhia
bb8880d09a
fix console README and isProduction check while setting globals (#3076) 2019-10-09 19:23:21 +05:30
Rakesh Emmadi
f3b418c631 support where clause in on_conflict of insert mutation (close #2795) (#3002) 2019-10-09 05:09:20 -05:00
Rishichandra Wawhal
d3f80265f5 update graphiql explorer in hasura console and graphiql online (closes #2313) (#2994)
* update graphiql explorer

* update onegraph explorer in graphiql online
2019-10-08 16:17:18 +05:30