Commit 5b4d988
authored
Introduce 'create-init' command to load a new database from schema/data (#303)
## Usage and product changes
We introduce a new command `database create-init`, which
1) create the new database
2) loads a provided schema file (from URL, or from local file)
3) loads a provided data file (from URL or from local file)
Command format:
```
database create-init <db> <schema file> <data file> <[optional] schema file sha256 (hex or sha256:hex)> <[optional] data file sha256 (hex or sha256:hex)>
```
Usage example to load bookstore example from `typedb-examples`:
```
>> database create-init bookstore https://github.com/typedb/typedb-examples/releases/download/3.5.0/bookstore-schema.tql https://github.com/typedb/typedb-examples/releases/download/3.5.0/bookstore-data.tql
```
You can also optionally provide sha256 checksums to verify your files
are correct (these come from the Github releases page):
```
>> database create-init bookstore https://github.com/typedb/typedb-examples/releases/download/3.5.0/bookstore-schema.tql https://github.com/typedb/typedb-examples/releases/download/3.5.0/bookstore-data.tql sha256:b2de488d9f64ccdfdba016029c7932be69ec5d35d18977c85bb12ad4cc97e95f sha256:828806afe1ce939d0ee87d6ae89598f5d7f967155c7757263b151673480bcad1
```
We've also upgraded the `source` command in a transaction to allow
reading from a remote URL, not just local files:
```
bookstore::write >> source https://github.com/typedb/typedb-examples/releases/download/3.5.0/bookstore-data.tql
```
This can also optionally take a sha256 (the `sha256:` prefix optional):
```
bookstore::write >> source https://github.com/typedb/typedb-examples/releases/download/3.5.0/bookstore-data.tql 828806afe1ce939d0ee87d6ae89598f5d7f967155c7757263b151673480bcad1
```
These commands can also receive local in relative or absolute path
formats.
## Implementation
Chain together database creation, and schema+data file sourcing.
Extend the existing `source` behaviour to allow retriving the file over
the network from a remote URL.
Refactor the help menu to make it handle the long content more
effectively.1 parent b847513 commit 5b4d988
File tree
8 files changed
+292
-97
lines changed- src
- repl
8 files changed
+292
-97
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
26 | 51 | | |
27 | 52 | | |
28 | 53 | | |
| |||
33 | 58 | | |
34 | 59 | | |
35 | 60 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | 61 | | |
42 | 62 | | |
43 | 63 | | |
| |||
50 | 70 | | |
51 | 71 | | |
52 | 72 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
61 | 76 | | |
62 | 77 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
| 322 | + | |
322 | 323 | | |
323 | 324 | | |
324 | 325 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
343 | | - | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
346 | 359 | | |
347 | 360 | | |
348 | 361 | | |
349 | | - | |
| 362 | + | |
350 | 363 | | |
351 | 364 | | |
352 | 365 | | |
353 | 366 | | |
354 | 367 | | |
355 | | - | |
| 368 | + | |
356 | 369 | | |
357 | 370 | | |
358 | 371 | | |
359 | 372 | | |
360 | | - | |
| 373 | + | |
361 | 374 | | |
362 | | - | |
363 | | - | |
364 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
365 | 378 | | |
366 | 379 | | |
367 | 380 | | |
368 | 381 | | |
369 | 382 | | |
370 | 383 | | |
371 | 384 | | |
372 | | - | |
| 385 | + | |
373 | 386 | | |
374 | 387 | | |
375 | | - | |
376 | 388 | | |
377 | 389 | | |
378 | | - | |
379 | | - | |
| 390 | + | |
| 391 | + | |
380 | 392 | | |
381 | 393 | | |
382 | 394 | | |
| |||
387 | 399 | | |
388 | 400 | | |
389 | 401 | | |
390 | | - | |
391 | | - | |
| 402 | + | |
| 403 | + | |
392 | 404 | | |
393 | 405 | | |
394 | 406 | | |
395 | 407 | | |
396 | 408 | | |
397 | 409 | | |
398 | | - | |
| 410 | + | |
399 | 411 | | |
400 | 412 | | |
401 | 413 | | |
402 | 414 | | |
403 | 415 | | |
404 | 416 | | |
405 | | - | |
406 | | - | |
| 417 | + | |
| 418 | + | |
407 | 419 | | |
408 | 420 | | |
409 | 421 | | |
| |||
412 | 424 | | |
413 | 425 | | |
414 | 426 | | |
415 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
416 | 432 | | |
417 | 433 | | |
418 | 434 | | |
419 | 435 | | |
420 | 436 | | |
421 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
422 | 442 | | |
423 | 443 | | |
424 | 444 | | |
425 | 445 | | |
426 | 446 | | |
427 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
428 | 452 | | |
429 | 453 | | |
430 | 454 | | |
| |||
457 | 481 | | |
458 | 482 | | |
459 | 483 | | |
460 | | - | |
| 484 | + | |
461 | 485 | | |
462 | | - | |
463 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
464 | 491 | | |
465 | 492 | | |
466 | 493 | | |
467 | 494 | | |
468 | 495 | | |
469 | 496 | | |
470 | | - | |
| 497 | + | |
471 | 498 | | |
472 | 499 | | |
473 | 500 | | |
| |||
0 commit comments