mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-10-19 09:16:09 +00:00
Fix template cardinalities (#404)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { Cardinality } from "../data/constants";
|
||||||
|
|
||||||
export const template1 = {
|
export const template1 = {
|
||||||
tables: [
|
tables: [
|
||||||
{
|
{
|
||||||
@@ -289,7 +291,7 @@ export const template1 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "blog_posts_user_id_fk",
|
name: "blog_posts_user_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -300,7 +302,7 @@ export const template1 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "comments_blog_id_fk",
|
name: "comments_blog_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -311,7 +313,7 @@ export const template1 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "comments_user_id_fk",
|
name: "comments_user_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -322,7 +324,7 @@ export const template1 = {
|
|||||||
endTableId: 3,
|
endTableId: 3,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "blog_tag_tag_id_fk",
|
name: "blog_tag_tag_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 3,
|
id: 3,
|
||||||
@@ -333,7 +335,7 @@ export const template1 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "blog_tag_blog_id_fk",
|
name: "blog_tag_blog_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 4,
|
id: 4,
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import { Cardinality } from "../data/constants";
|
||||||
|
|
||||||
export const template2 = {
|
export const template2 = {
|
||||||
tables: [
|
tables: [
|
||||||
{
|
{
|
||||||
@@ -304,7 +306,7 @@ export const template2 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "employees_dep_id_fk",
|
name: "employees_dep_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -315,7 +317,7 @@ export const template2 = {
|
|||||||
endTableId: 2,
|
endTableId: 2,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "employees_pos_id_fk",
|
name: "employees_pos_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -326,7 +328,7 @@ export const template2 = {
|
|||||||
endTableId: 3,
|
endTableId: 3,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "project_assignment_project_id_fk",
|
name: "project_assignment_project_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -337,7 +339,7 @@ export const template2 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "project_assignment_employee_id_fk",
|
name: "project_assignment_employee_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 3,
|
id: 3,
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import { Cardinality } from "../data/constants";
|
||||||
|
|
||||||
export const template3 = {
|
export const template3 = {
|
||||||
tables: [
|
tables: [
|
||||||
{
|
{
|
||||||
@@ -365,7 +367,7 @@ export const template3 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "order_product_id_fk",
|
name: "order_product_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -376,7 +378,7 @@ export const template3 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "products_category_id_fk",
|
name: "products_category_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -387,7 +389,7 @@ export const template3 = {
|
|||||||
endTableId: 4,
|
endTableId: 4,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "reviews_customer_id_fk",
|
name: "reviews_customer_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -398,7 +400,7 @@ export const template3 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "reviews_product_id_fk",
|
name: "reviews_product_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 3,
|
id: 3,
|
||||||
@@ -409,7 +411,7 @@ export const template3 = {
|
|||||||
endTableId: 4,
|
endTableId: 4,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "orders_customer_id_fk",
|
name: "orders_customer_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 4,
|
id: 4,
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import { Cardinality } from "../data/constants";
|
||||||
|
|
||||||
export const template4 = {
|
export const template4 = {
|
||||||
tables: [
|
tables: [
|
||||||
{
|
{
|
||||||
@@ -316,7 +318,7 @@ export const template4 = {
|
|||||||
endTableId: 2,
|
endTableId: 2,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "books_author_id_fk",
|
name: "books_author_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -327,7 +329,7 @@ export const template4 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "reservations_book_id_fk",
|
name: "reservations_book_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -338,7 +340,7 @@ export const template4 = {
|
|||||||
endTableId: 4,
|
endTableId: 4,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "reservations_patron_id_fk",
|
name: "reservations_patron_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -349,7 +351,7 @@ export const template4 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "books_genre_id_fk",
|
name: "books_genre_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 3,
|
id: 3,
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import { Cardinality } from "../data/constants";
|
||||||
|
|
||||||
export const template5 = {
|
export const template5 = {
|
||||||
tables: [
|
tables: [
|
||||||
{
|
{
|
||||||
@@ -554,7 +556,7 @@ export const template5 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "accounts_customer_id_fk",
|
name: "accounts_customer_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -565,7 +567,7 @@ export const template5 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "cards_customer_id_fk",
|
name: "cards_customer_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -576,7 +578,7 @@ export const template5 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "loans_customer_id_fk",
|
name: "loans_customer_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -587,7 +589,7 @@ export const template5 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "investments_customer_id_fk",
|
name: "investments_customer_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 3,
|
id: 3,
|
||||||
@@ -598,7 +600,7 @@ export const template5 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "transactions_account_id_fk",
|
name: "transactions_account_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 4,
|
id: 4,
|
||||||
@@ -609,7 +611,7 @@ export const template5 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "transfers_to_fk",
|
name: "transfers_to_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 5,
|
id: 5,
|
||||||
@@ -620,7 +622,7 @@ export const template5 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "transfers_from_fk",
|
name: "transfers_from_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 6,
|
id: 6,
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import { Cardinality } from "../data/constants";
|
||||||
|
|
||||||
export const template6 = {
|
export const template6 = {
|
||||||
tables: [
|
tables: [
|
||||||
{
|
{
|
||||||
@@ -400,7 +402,7 @@ export const template6 = {
|
|||||||
endTableId: 0,
|
endTableId: 0,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "enrollment_student_id_fk",
|
name: "enrollment_student_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 0,
|
id: 0,
|
||||||
@@ -411,7 +413,7 @@ export const template6 = {
|
|||||||
endTableId: 1,
|
endTableId: 1,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "enrollment_course_id_fk",
|
name: "enrollment_course_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 1,
|
id: 1,
|
||||||
@@ -422,7 +424,7 @@ export const template6 = {
|
|||||||
endTableId: 4,
|
endTableId: 4,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "instructors_dep_id_fk",
|
name: "instructors_dep_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -433,7 +435,7 @@ export const template6 = {
|
|||||||
endTableId: 4,
|
endTableId: 4,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "courses_dep_id_fk",
|
name: "courses_dep_id_fk",
|
||||||
cardinality: "One to one",
|
cardinality: Cardinality.ONE_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 3,
|
id: 3,
|
||||||
@@ -444,7 +446,7 @@ export const template6 = {
|
|||||||
endTableId: 5,
|
endTableId: 5,
|
||||||
endFieldId: 0,
|
endFieldId: 0,
|
||||||
name: "students_major_id_fk",
|
name: "students_major_id_fk",
|
||||||
cardinality: "Many to one",
|
cardinality: Cardinality.MANY_TO_ONE,
|
||||||
updateConstraint: "No action",
|
updateConstraint: "No action",
|
||||||
deleteConstraint: "No action",
|
deleteConstraint: "No action",
|
||||||
id: 4,
|
id: 4,
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { Cardinality } from "../../data/constants";
|
import { Cardinality } from "../../data/constants";
|
||||||
|
import i18n from "../../i18n/i18n";
|
||||||
import { parseDefault } from "../exportSQL/shared";
|
import { parseDefault } from "../exportSQL/shared";
|
||||||
|
|
||||||
function columnDefault(field, database) {
|
function columnDefault(field, database) {
|
||||||
@@ -38,10 +39,13 @@ function columnSettings(field, database) {
|
|||||||
|
|
||||||
function cardinality(rel) {
|
function cardinality(rel) {
|
||||||
switch (rel.cardinality) {
|
switch (rel.cardinality) {
|
||||||
|
case i18n.t(Cardinality.ONE_TO_ONE):
|
||||||
case Cardinality.ONE_TO_ONE:
|
case Cardinality.ONE_TO_ONE:
|
||||||
return "-";
|
return "-";
|
||||||
|
case i18n.t(Cardinality.ONE_TO_MANY):
|
||||||
case Cardinality.ONE_TO_MANY:
|
case Cardinality.ONE_TO_MANY:
|
||||||
return "<";
|
return "<";
|
||||||
|
case i18n.t(Cardinality.MANY_TO_ONE):
|
||||||
case Cardinality.MANY_TO_ONE:
|
case Cardinality.MANY_TO_ONE:
|
||||||
return ">";
|
return ">";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user