| 421 | ==== Declarative migrations ==== |
| 422 | |
| 423 | In a declarative migration you can define 4 things: topic types, association types, topics, associations. The general format is: |
| 424 | |
| 425 | {{{ |
| 426 | #!js |
| 427 | { |
| 428 | topic_types: [ |
| 429 | ... |
| 430 | ], |
| 431 | assoc_types: [ |
| 432 | ... |
| 433 | ], |
| 434 | topics: [ |
| 435 | ... |
| 436 | ], |
| 437 | associations: [ |
| 438 | ... |
| 439 | ] |
| 440 | } |
| 441 | }}} |
| 442 | |
| 443 | Each of the 4 sections is optional. |
| 444 | |
| 445 | As an example see the (simplified) migration that defines the //Note// topic type. This migration is part of the //DeepaMehta 4 Notes// plugin: |
| 446 | |
| 447 | {{{ |
| 448 | #!js |
| 449 | { |
| 450 | topic_types: [ |
| 451 | { |
| 452 | value: "Title", |
| 453 | uri: "dm4.notes.title", |
| 454 | data_type_uri: "dm4.core.text", |
| 455 | index_mode_uris: ["dm4.core.fulltext"] |
| 456 | }, |
| 457 | { |
| 458 | value: "Text", |
| 459 | uri: "dm4.notes.text", |
| 460 | data_type_uri: "dm4.core.html", |
| 461 | index_mode_uris: ["dm4.core.fulltext"] |
| 462 | }, |
| 463 | { |
| 464 | value: "Note", |
| 465 | uri: "dm4.notes.note", |
| 466 | data_type_uri: "dm4.core.composite", |
| 467 | assoc_defs: [ |
| 468 | { |
| 469 | child_type_uri: "dm4.notes.title", |
| 470 | child_cardinality_uri: "dm4.core.one", |
| 471 | assoc_type_uri: "dm4.core.composition_def" |
| 472 | }, |
| 473 | { |
| 474 | child_type_uri: "dm4.notes.text", |
| 475 | child_cardinality_uri: "dm4.core.one", |
| 476 | assoc_type_uri: "dm4.core.composition_def" |
| 477 | } |
| 478 | ], |
| 479 | view_config_topics: [ |
| 480 | { |
| 481 | type_uri: "dm4.webclient.view_config", |
| 482 | composite: { |
| 483 | dm4.webclient.icon: "/de.deepamehta.notes/images/yellow-ball.png", |
| 484 | dm4.webclient.show_in_create_menu: true |
| 485 | } |
| 486 | } |
| 487 | ] |
| 488 | } |
| 489 | ] |
| 490 | } |
| 491 | }}} |
| 492 | |
| 493 | This migration defines 3 topic types: the 2 simple types //Title// and //Text//, and the composite type //Note// that combines the former two. That is, a Note is composed of a Title and a Text. |
| 494 | |
| 495 | ==== Imperative migrations ==== |