diff --git a/db/Models/assets/ETA_RBAC_model.svg b/db/Models/assets/ETA_RBAC_model.svg index 223d484..1773a09 100644 --- a/db/Models/assets/ETA_RBAC_model.svg +++ b/db/Models/assets/ETA_RBAC_model.svg @@ -1,5 +1,5 @@ - + @@ -60,14 +60,17 @@ - - - - + + + + + + + @@ -200,28 +203,28 @@ - + - + - + - + - + - - - + + + - + @@ -242,263 +245,339 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + - - - + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - + + + + + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -507,7 +586,7 @@ - + @@ -516,7 +595,7 @@ - + @@ -536,7 +615,7 @@ - + @@ -561,7 +640,7 @@ - + @@ -583,7 +662,7 @@ - + @@ -626,881 +705,1064 @@ - - - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + - - - - - + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + - - - - - - + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - - + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + + + - - - - - - + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + - - - - - - + + + + + + + + + + - + + - - - - - - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1523,7 +1785,7 @@ - + @@ -1532,7 +1794,7 @@ - + @@ -1555,7 +1817,7 @@ - + @@ -1581,7 +1843,7 @@ - + @@ -1596,12 +1858,12 @@ - - - + + + - + @@ -1623,7 +1885,7 @@ - + @@ -1645,7 +1907,7 @@ - + @@ -1751,7 +2013,7 @@ - + @@ -1763,7 +2025,7 @@ - + @@ -1772,7 +2034,7 @@ - + @@ -1786,7 +2048,7 @@ - + @@ -1820,7 +2082,7 @@ - + @@ -1842,7 +2104,7 @@ - + @@ -1864,7 +2126,7 @@ - + @@ -1886,7 +2148,7 @@ - + @@ -1982,7 +2244,7 @@ - + @@ -1991,7 +2253,7 @@ - + @@ -2000,7 +2262,7 @@ - + @@ -2017,7 +2279,7 @@ - + @@ -2027,19 +2289,19 @@ - + - + - + @@ -2050,7 +2312,7 @@ - + @@ -2071,7 +2333,7 @@ - + @@ -2085,12 +2347,12 @@ - - - + + + - + @@ -2109,11 +2371,11 @@ - - + + - + @@ -2131,11 +2393,11 @@ - - + + - + @@ -2157,11 +2419,11 @@ - - + + - + @@ -2174,7 +2436,7 @@ - + @@ -2187,7 +2449,7 @@ - + @@ -2199,7 +2461,7 @@ - + @@ -2211,7 +2473,7 @@ - + @@ -2225,7 +2487,7 @@ - + @@ -2237,12 +2499,12 @@ - + - + @@ -2250,7 +2512,7 @@ - + @@ -2263,7 +2525,7 @@ - + @@ -2284,7 +2546,7 @@ - + @@ -2306,7 +2568,7 @@ - + @@ -2328,13 +2590,13 @@ - + - + @@ -2347,13 +2609,13 @@ - + - + @@ -2487,843 +2749,901 @@ - - - + + + - - - - - - - - - + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + - - - - + + - - - - - - - - - + + + + + + - - + - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + @@ -3338,9 +3658,10 @@ + - - + + @@ -3349,7 +3670,7 @@ - + @@ -3363,7 +3684,7 @@ - + @@ -3377,12 +3698,12 @@ - - - + + + - + @@ -3404,7 +3725,7 @@ - + @@ -3426,7 +3747,7 @@ - + @@ -3447,10 +3768,10 @@ - + - + @@ -3459,7 +3780,7 @@ - + @@ -3471,10 +3792,10 @@ - + - + @@ -3484,7 +3805,7 @@ - + @@ -3539,1111 +3860,1102 @@ - - - - + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + @@ -4651,7 +4963,7 @@ - + @@ -4662,7 +4974,7 @@ - + @@ -4671,7 +4983,7 @@ - + @@ -4688,7 +5000,7 @@ - + @@ -4706,14 +5018,14 @@ - - + + - + - + @@ -4726,836 +5038,2796 @@ - + - + - - + + - - + + - - + + - - + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + - - - - - - - + + + + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - + + + + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/db/Models/eta_rbac.mwb b/db/Models/eta_rbac.mwb index dc4ce00..8182af6 100644 Binary files a/db/Models/eta_rbac.mwb and b/db/Models/eta_rbac.mwb differ diff --git a/db/Models/eta_rbac_requirements.md b/db/Models/eta_rbac_requirements.md new file mode 100644 index 0000000..bbc9176 --- /dev/null +++ b/db/Models/eta_rbac_requirements.md @@ -0,0 +1,204 @@ +# ETA RBAC and Domain Data Requirements + +This document translates SQL constraints from the schema into software requirements language. + +## 1. Global Requirements + +1. The system shall store all data in the schema `u947463964_etaviaporte`. +2. Each table shall use an auto-generated unsigned integer `id` as primary key. +3. Every foreign-keyed record shall reference an existing parent record. + +## 2. Users and Authentication + +1. A user shall provide `name` and `last_name`. +2. A user record shall always include `created_at` and `updated_at` timestamps. +3. An auth identity shall always belong to an existing user. +4. An auth identity shall include `provider` and `identifier`. +5. The combination of `provider` and `identifier` shall be unique. +6. Auth identity flags `is_primary` and `is_verified` shall default to `0` (false). +7. Deleting a user shall delete the user auth identities. + +## 3. Applications, Roles, and Permissions + +1. An application shall include unique `name` and unique `slug`. +2. A role shall always belong to an existing application. +3. A role name shall be unique within its application. +4. A permission shall always belong to an existing application. +5. A permission name shall be unique within its application. +6. A permission record shall include `created_at` and `updated_at` timestamps. +7. A role-permission assignment shall reference an existing role, permission, and application. +8. The pair `(role_id, permission_id)` shall be unique. +9. Deleting an application, role, or permission shall delete related role-permission assignments. +10. A user-role assignment shall reference an existing user, role, and application. +11. The pair `(user_id, role_id)` shall be unique. +12. Deleting a user, role, or application shall delete related user-role assignments. +13. A user shall be allowed to have multiple roles as long as each `(user_id, role_id)` pair is unique. + +## 4. Verification and Sessions + +1. A verification token shall belong to an existing auth identity. +2. A verification token shall include unique `token_hash`. +3. Verification token purpose shall be one of: `email_verification`, `phone_verification`, `password_reset`. +4. A verification token shall include `created_at` and `expires_at`. +5. Deleting an auth identity shall delete related verification tokens. +6. A session shall belong to an existing user. +7. A session shall include unique `session_token_hash`. +8. A session shall include `created_at`, `updated_at`, and `expires_at`. +9. Deleting a user shall delete related sessions. + +## 5. Companies and Locations + +1. A company shall include `name`. +2. Company `privacy_enabled` shall default to `0`. +3. Company `disabled` shall default to `0`. +4. A location shall belong to an existing company. +5. A location shall include `state`, `city`, `country`, `zipcode`, and `address_line1`. +6. Location type shall be one of: `loading`, `unloading`, `both`. +7. Location type shall default to `both`. +8. Location coordinates, when present, shall be stored as decimal latitude and longitude values. +9. Deleting a company shall delete its locations. + +## 6. Loads, Vehicles, and Shipment Lifecycle + +1. A load shall belong to an existing company and an existing creator user. +2. Load status shall be one of: `Draft`, `Published`, `Completed`, `Closed`, `Cancelled`. +3. Load status shall default to `Draft`. +4. A load shall include `product`, `sector`, and `truck_type`. +5. Load `privacy_enabled` shall default to `0`. +6. Load `disabled` shall default to `0`. +7. If an origin or destination location is deleted, the corresponding load reference shall be set to `NULL`. +8. Deleting the load creator user shall delete the load. +9. Deleting the load company shall delete the load. +10. A vehicle shall belong to an existing company. +11. A vehicle shall include `VIN` and `truck_plate`. +12. Vehicle status shall be one of: `Available`, `Busy`. +13. Vehicle status shall default to `Available`. +14. A company shall not repeat the same vehicle VIN (`(company_id, VIN)` unique). +15. A company shall not repeat the same truck plate (`(company_id, truck_plate)` unique). +16. A driver shall be assigned to at most one vehicle at a time (`driver_id` unique). +17. A load shall be assigned to at most one vehicle at a time (`load_id` unique). +18. If a driver user is deleted, the vehicle driver reference shall be set to `NULL`. +19. If an assigned load is deleted, the vehicle load reference shall be set to `NULL`. +20. Deleting a company shall delete its vehicles. +21. A load shipment shall belong to an existing load. +22. A load shipment status shall be one of: `Assigned`, `Loading`, `Transit`, `Unloading`, `Delivered`. +23. A load shipment status shall default to `Assigned`. +24. Shipment tracking coordinates, when present, shall be stored as decimal latitude and longitude values. +25. Each load shall have at most one load shipment (`load_id` unique). +26. Deleting a load shall delete its load shipment. +27. A shipment evidence record shall belong to an existing load. +28. Shipment evidence type shall be one of: `loading`, `unloading`. +29. A load shall have at most one evidence per evidence type (`(load_id, type)` unique). +30. Deleting a load shall delete shipment evidences. +31. A shipment proposal shall belong to an existing load and an existing user (`created_by`). +32. If a proposed vehicle is deleted, the shipment proposal vehicle reference shall be set to `NULL`. +33. Deleting a load shall delete shipment proposals. +34. Deleting the creator user shall delete shipment proposals. +35. A shipment agreement shall reference an existing load, shipment proposal, and accepting user. +36. A load shall have at most one shipment agreement (`load_id` unique). +37. Deleting a load, shipment proposal, or accepting user shall delete shipment agreements. + +## 7. Master Data and Categorization + +1. Sector names in `meta_sectors` shall be unique. +2. A sector record shall include `created_at` and `updated_at` timestamps. +3. Vehicle type names in `meta_vehicle_types` shall be unique. +4. A vehicle type record shall include `created_at` and `updated_at` timestamps. +5. Product names in `meta_products` shall be unique. +6. A product record shall include `created_at` and `updated_at` timestamps. +7. A city record shall include `city`, `state`, and `country`. +8. A city record shall include `created_at` and `updated_at` timestamps. +9. A company sector shall belong to an existing company. +10. A company shall not repeat the same sector (`(company_id, sector)` unique). +11. Deleting a company shall delete its company sectors. +12. A company vehicle type shall belong to an existing company. +13. A company shall not repeat the same vehicle type (`(company_id, truck_type)` unique). +14. Deleting a company shall delete its company vehicle types. +15. A location-category assignment shall reference an existing location and existing company sector. +16. A location shall not repeat the same category (`(location_id, category_id)` unique). +17. Deleting a location or company sector shall delete related location-category assignments. +18. A vehicle-type assignment shall reference an existing vehicle and existing company vehicle type. +19. A vehicle shall not repeat the same type (`(vehicle_id, type_id)` unique). +20. Deleting a vehicle or company vehicle type shall delete related vehicle-type assignments. +21. A user-location assignment shall reference an existing user and existing location. +22. A user shall not repeat the same location (`(user_id, location_id)` unique). +23. Deleting a user or location shall delete related user-location assignments. + +## 8. Templates, Memberships, and Privacy + +1. A load template shall belong to an existing company and creator user. +2. A load template shall include `name`. +3. A user shall not create duplicate load template names inside the same company (`(company_id, created_by, name)` unique). +4. Deleting a company shall delete related load templates. +5. Deleting a creator user shall delete related load templates. +6. Deleting an origin or destination location referenced by a load template shall set that location reference to `NULL`. +7. A user-application assignment shall reference an existing user and existing application. +8. A user shall be allowed to be added to multiple applications. +9. A user shall not be assigned to the same application more than once (`(user_id, application_id)` unique). +10. Deleting a user or application shall delete related user-application assignments. +11. A company-user assignment shall reference an existing user and existing company. +12. A company-user assignment shall include `created_at`. +13. A user shall be assigned to only one company (`user_id` unique in `company_users`). +14. Deleting a user or company shall delete related company-user assignments. +15. A privacy group shall belong to an existing company. +16. Privacy group names shall be unique per company (`(company_id, name)` unique). +17. Deleting a company shall delete its privacy groups. +18. A privacy group company rule shall reference an existing company, privacy group, and allowed company. +19. An allowed company shall not be repeated within the same privacy group (`(group_id, allowed_company_id)` unique). +20. Deleting a company or privacy group shall delete related privacy group company rules. + +## 9. Alert Email Constraints + +1. A load alert email record shall belong to an existing load. +2. The same email shall not be repeated for the same load (`(load_id, email)` unique). +3. Deleting a load shall delete load alert emails. +4. A warehouse alert email record shall belong to an existing warehouse location. +5. The same email shall not be repeated for the same warehouse (`(warehouse_id, email)` unique). +6. Deleting a warehouse location shall delete warehouse alert emails. + +## 10. Identity and Access Interpretation + +1. A user shall be authorized using an identity provider and identifier pair, such as email address or phone number. +2. A provider-specific identifier shall map to one and only one auth identity record. +3. A role and permission model shall be scoped by application. + +## 11. Company Compliance and Documents + +1. A company status record shall belong to an existing company. +2. A company shall have at most one company status record (`company_id` unique). +3. Company status shall be one of: `Registered`, `InReview`, `Enabled`, `Disabled`. +4. Company status shall default to `Registered`. +5. A company status record shall include `notes` (NOT NULL). +6. A company status record shall include `created_at` and `updated_at` timestamps. +7. Deleting a company shall delete related company status records. +8. A company document shall belong to an existing company. +9. A company document shall include `document_id` and `name`. +10. Company document status shall be one of: `New`, `InReview`, `Approved`, `Rejected`. +11. Company document status shall default to `New`. +12. A company document shall include `status_notes` (NOT NULL). +13. A company document record shall include `created_at` and `updated_at` timestamps. +14. A company shall not repeat document names (`(company_id, name)` unique). +15. Deleting a company shall delete related company documents. + +## 12. API Key and Permission Model + +1. An API key record shall include `name` and `key_hash`. +2. API key hashes shall be globally unique. +3. An API key shall belong to an existing application. +4. An API key record shall include `created_at` and `updated_at` timestamps. +5. Deleting an application shall delete related API keys. +6. An API key permission record shall belong to an existing application, permission, and API key. +7. API key permission assignments shall include `created_at`. +8. An API key shall not repeat the same permission assignment (`(apikey_id, permission_id)` unique). +9. Deleting an application, permission, or API key shall delete related API key permission assignments. + +## 13. Vehicle Documents + +1. A vehicle document shall belong to an existing company and an existing vehicle. +2. A vehicle document shall include `document_id` and `name`. +3. Vehicle document status shall be one of: `New`, `InReview`, `Approved`, `Rejected`. +4. Vehicle document status shall default to `New`. +5. A vehicle document shall include `status_notes` (NOT NULL). +6. A vehicle document record shall include `created_at` and `updated_at` timestamps. +7. A company shall not repeat vehicle document names (`(company_id, name)` unique). +8. Deleting a company or vehicle shall delete related vehicle documents. diff --git a/db/Models/schemas/eta_rbac.sql b/db/Models/schemas/eta_rbac.sql index 77b2b30..8b671e2 100644 --- a/db/Models/schemas/eta_rbac.sql +++ b/db/Models/schemas/eta_rbac.sql @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- Wed 01 Apr 2026 02:54:57 PM CST +-- Wed 01 Apr 2026 05:30:16 PM CST -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -99,6 +99,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`permissions` ( `application_id` INT UNSIGNED NOT NULL, `name` VARCHAR(512) NOT NULL, `description` TEXT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`application_id` ASC, `name` ASC) VISIBLE, INDEX `fk_permissions_applications1_idx` (`application_id` ASC) VISIBLE, @@ -229,7 +231,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`companies` ( `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `disabled` TINYINT NOT NULL DEFAULT 0 COMMENT 'This field allows blocking publications based on business rules', - `disabled_at` VARCHAR(45) NULL, + `disabled_at` DATETIME NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; @@ -247,8 +249,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`locations` ( `zipcode` VARCHAR(10) NOT NULL, `address_line1` VARCHAR(512) NOT NULL, `address_line2` VARCHAR(512) NULL, - `lat` VARCHAR(128) NULL, - `lng` VARCHAR(128) NULL, + `lat` DECIMAL(10,8) NULL, + `lng` DECIMAL(10,8) NULL, `name` VARCHAR(512) NULL, `description` TEXT NULL, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -272,7 +274,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`loads` ( `created_by` INT UNSIGNED NOT NULL, `origin_id` INT UNSIGNED NULL, `destination_id` INT UNSIGNED NULL, - `status` ENUM('Draft', 'Published', 'Completed', 'Closed', 'Cancel') NOT NULL DEFAULT 'Draft', + `status` ENUM('Draft', 'Published', 'Completed', 'Closed', 'Cancelled') NOT NULL DEFAULT 'Draft', `product` VARCHAR(100) NOT NULL COMMENT 'Maiz, Trigo, etc', `sector` VARCHAR(100) NOT NULL COMMENT 'Automotriz, Agricola, etc', `truck_type` VARCHAR(100) NOT NULL, @@ -322,6 +324,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicles` ( `company_id` INT UNSIGNED NOT NULL, `driver_id` INT UNSIGNED NULL, `load_id` INT UNSIGNED NULL, + `status` ENUM('Available', 'Busy') NOT NULL DEFAULT 'Available', `VIN` VARCHAR(45) NOT NULL, `truck_plate` VARCHAR(45) NOT NULL, `trailer_plate_1` VARCHAR(45) NULL, @@ -332,6 +335,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicles` ( INDEX `fk_vehicles_companies1_idx` (`company_id` ASC) VISIBLE, UNIQUE INDEX `driver_id_UNIQUE` (`driver_id` ASC) VISIBLE, UNIQUE INDEX `load_id_UNIQUE` (`load_id` ASC) VISIBLE, + UNIQUE INDEX `VIN_UNIQUE` (`company_id` ASC, `VIN` ASC) VISIBLE, + UNIQUE INDEX `truck_plate_UNIQUE` (`company_id` ASC, `truck_plate` ASC) VISIBLE, CONSTRAINT `fk_vehicles_companies1` FOREIGN KEY (`company_id`) REFERENCES `u947463964_etaviaporte`.`companies` (`id`) @@ -359,8 +364,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`load_shipments` ( `status` ENUM('Assigned', 'Loading', 'Transit', 'Unloading', 'Delivered') NOT NULL DEFAULT 'Assigned', `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `last_lat` VARCHAR(128) NULL, - `last_lng` VARCHAR(128) NULL, + `last_lat` DECIMAL(10,8) NULL, + `last_lng` DECIMAL(10,8) NULL, PRIMARY KEY (`id`), INDEX `fk_load_shipment_loads1_idx` (`load_id` ASC) VISIBLE, UNIQUE INDEX `load_id_UNIQUE` (`load_id` ASC) VISIBLE, @@ -405,22 +410,22 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`shipment_proposals` ( `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_shipment_proposals_loads1_idx` (`load_id` ASC) VISIBLE, - INDEX `fk_shipment_proposals_user_roles1_idx` (`created_by` ASC) VISIBLE, INDEX `fk_shipment_proposals_vehicles1_idx` (`vehicle_id` ASC) VISIBLE, + INDEX `fk_shipment_proposals_users1_idx` (`created_by` ASC) VISIBLE, CONSTRAINT `fk_shipment_proposals_loads1` FOREIGN KEY (`load_id`) REFERENCES `u947463964_etaviaporte`.`loads` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT `fk_shipment_proposals_user_roles1` - FOREIGN KEY (`created_by`) - REFERENCES `u947463964_etaviaporte`.`user_roles` (`id`) - ON DELETE CASCADE - ON UPDATE NO ACTION, CONSTRAINT `fk_shipment_proposals_vehicles1` FOREIGN KEY (`vehicle_id`) REFERENCES `u947463964_etaviaporte`.`vehicles` (`id`) ON DELETE SET NULL + ON UPDATE NO ACTION, + CONSTRAINT `fk_shipment_proposals_users1` + FOREIGN KEY (`created_by`) + REFERENCES `u947463964_etaviaporte`.`users` (`id`) + ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -438,8 +443,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`shipment_agreements` ( PRIMARY KEY (`id`), INDEX `fk_shipment_proposal_agreement_loads1_idx` (`load_id` ASC) VISIBLE, INDEX `fk_shipment_proposal_agreement_shipment_proposals1_idx` (`proposal_id` ASC) VISIBLE, - INDEX `fk_shipment_proposal_agreement_user_roles1_idx` (`accepted_by` ASC) VISIBLE, UNIQUE INDEX `load_id_UNIQUE` (`load_id` ASC) VISIBLE, + INDEX `fk_shipment_agreements_users1_idx` (`accepted_by` ASC) VISIBLE, CONSTRAINT `fk_shipment_proposal_agreement_loads1` FOREIGN KEY (`load_id`) REFERENCES `u947463964_etaviaporte`.`loads` (`id`) @@ -450,9 +455,9 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`shipment_agreements` ( REFERENCES `u947463964_etaviaporte`.`shipment_proposals` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT `fk_shipment_proposal_agreement_user_roles1` + CONSTRAINT `fk_shipment_agreements_users1` FOREIGN KEY (`accepted_by`) - REFERENCES `u947463964_etaviaporte`.`user_roles` (`id`) + REFERENCES `u947463964_etaviaporte`.`users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -464,17 +469,21 @@ ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_sectors` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `sector` VARCHAR(100) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `sector_UNIQUE` (`sector` ASC) VISIBLE) ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `u947463964_etaviaporte`.`meta_truck_types` +-- Table `u947463964_etaviaporte`.`meta_vehicle_types` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_truck_types` ( +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_vehicle_types` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `type` VARCHAR(100) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `meta_truck_typescol_UNIQUE` (`type` ASC) VISIBLE) ENGINE = InnoDB; @@ -486,6 +495,8 @@ ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_products` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `product` VARCHAR(100) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `product_UNIQUE` (`product` ASC) VISIBLE) ENGINE = InnoDB; @@ -500,6 +511,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_cities` ( `state` VARCHAR(100) NOT NULL, `country` VARCHAR(100) NOT NULL, `zipcode` VARCHAR(100) NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; @@ -522,9 +535,9 @@ ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `u947463964_etaviaporte`.`company_truck_types` +-- Table `u947463964_etaviaporte`.`company_vehicle_types` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_truck_types` ( +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_vehicle_types` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `company_id` INT UNSIGNED NOT NULL, `truck_type` VARCHAR(100) NOT NULL, @@ -562,9 +575,9 @@ ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `u947463964_etaviaporte`.`truck_types` +-- Table `u947463964_etaviaporte`.`vehicle_types` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`truck_types` ( +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicle_types` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `vehicle_id` INT UNSIGNED NOT NULL, `type_id` INT UNSIGNED NOT NULL, @@ -578,7 +591,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`truck_types` ( ON UPDATE NO ACTION, CONSTRAINT `fk_vehicle_types_company_truck_types1` FOREIGN KEY (`type_id`) - REFERENCES `u947463964_etaviaporte`.`company_truck_types` (`id`) + REFERENCES `u947463964_etaviaporte`.`company_vehicle_types` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -633,22 +646,22 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`load_templates` ( CONSTRAINT `fk_load_templates_companies1` FOREIGN KEY (`company_id`) REFERENCES `u947463964_etaviaporte`.`companies` (`id`) - ON DELETE NO ACTION + ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_load_templates_locations1` FOREIGN KEY (`origin_id`) REFERENCES `u947463964_etaviaporte`.`locations` (`id`) - ON DELETE NO ACTION + ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT `fk_load_templates_locations2` FOREIGN KEY (`destination_id`) REFERENCES `u947463964_etaviaporte`.`locations` (`id`) - ON DELETE NO ACTION + ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT `fk_load_templates_users1` FOREIGN KEY (`created_by`) REFERENCES `u947463964_etaviaporte`.`users` (`id`) - ON DELETE NO ACTION + ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -684,7 +697,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_users` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT UNSIGNED NOT NULL, `company_id` INT UNSIGNED NOT NULL, - `created_at` DATETIME NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) VISIBLE, INDEX `fk_company_users_companies1_idx` (`company_id` ASC) VISIBLE, @@ -787,6 +800,133 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`warehouse_alert_emails` ( ENGINE = InnoDB; +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`company_status` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_status` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `company_id` INT UNSIGNED NOT NULL, + `status` ENUM('Registered', 'InReview', 'Enabled', 'Disabled') NOT NULL DEFAULT 'Registered', + `notes` TEXT NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_company_status_companies1_idx` (`company_id` ASC) VISIBLE, + UNIQUE INDEX `company_id_UNIQUE` (`company_id` ASC) VISIBLE, + CONSTRAINT `fk_company_status_companies1` + FOREIGN KEY (`company_id`) + REFERENCES `u947463964_etaviaporte`.`companies` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`company_documents` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_documents` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `company_id` INT UNSIGNED NOT NULL, + `document_id` VARCHAR(255) NOT NULL, + `name` VARCHAR(512) NOT NULL, + `status` ENUM('New', 'InReview', 'Approved', 'Rejected') NOT NULL DEFAULT 'New', + `status_notes` TEXT NOT NULL COMMENT 'Add metadata like user who reviewed and reason behind the status assigned', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_company_documents_companies1_idx` (`company_id` ASC) VISIBLE, + UNIQUE INDEX `name_UNIQUE` (`company_id` ASC, `name` ASC) VISIBLE, + CONSTRAINT `fk_company_documents_companies1` + FOREIGN KEY (`company_id`) + REFERENCES `u947463964_etaviaporte`.`companies` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`apikeys` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`apikeys` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `application_id` INT UNSIGNED NOT NULL, + `name` VARCHAR(512) NOT NULL, + `description` TEXT NULL, + `key_hash` VARCHAR(255) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `expires_at` DATETIME NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `key_hash_UNIQUE` (`key_hash` ASC) VISIBLE, + CONSTRAINT `fk_apikeys_applications1` + FOREIGN KEY (`application_id`) + REFERENCES `u947463964_etaviaporte`.`applications` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`apikey_permissions` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`apikey_permissions` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `application_id` INT UNSIGNED NOT NULL, + `permission_id` INT UNSIGNED NOT NULL, + `apikey_id` INT UNSIGNED NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_apikey_permissions_permissions1_idx` (`permission_id` ASC) VISIBLE, + INDEX `fk_apikey_permissions_apikeys1_idx` (`apikey_id` ASC) VISIBLE, + UNIQUE INDEX `apikey_id_UNIQUE` (`apikey_id` ASC, `permission_id` ASC) VISIBLE, + CONSTRAINT `fk_apikey_permissions_applications1` + FOREIGN KEY (`application_id`) + REFERENCES `u947463964_etaviaporte`.`applications` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_apikey_permissions_permissions1` + FOREIGN KEY (`permission_id`) + REFERENCES `u947463964_etaviaporte`.`permissions` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_apikey_permissions_apikeys1` + FOREIGN KEY (`apikey_id`) + REFERENCES `u947463964_etaviaporte`.`apikeys` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`vehicle_documents` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicle_documents` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `company_id` INT UNSIGNED NOT NULL, + `vehicle_id` INT UNSIGNED NOT NULL, + `document_id` VARCHAR(255) NOT NULL, + `name` VARCHAR(512) NOT NULL, + `status` ENUM('New', 'InReview', 'Approved', 'Rejected') NOT NULL DEFAULT 'New', + `status_notes` TEXT NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_vehicle_documents_companies1_idx` (`company_id` ASC) VISIBLE, + INDEX `fk_vehicle_documents_vehicles1_idx` (`vehicle_id` ASC) VISIBLE, + UNIQUE INDEX `name_UNIQUE` (`company_id` ASC, `name` ASC) VISIBLE, + CONSTRAINT `fk_vehicle_documents_companies1` + FOREIGN KEY (`company_id`) + REFERENCES `u947463964_etaviaporte`.`companies` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_vehicle_documents_vehicles1` + FOREIGN KEY (`vehicle_id`) + REFERENCES `u947463964_etaviaporte`.`vehicles` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; diff --git a/db/service/initdb/00-schema.sql b/db/service/initdb/00-schema.sql index 77b2b30..8b671e2 100644 --- a/db/service/initdb/00-schema.sql +++ b/db/service/initdb/00-schema.sql @@ -1,5 +1,5 @@ -- MySQL Script generated by MySQL Workbench --- Wed 01 Apr 2026 02:54:57 PM CST +-- Wed 01 Apr 2026 05:30:16 PM CST -- Model: New Model Version: 1.0 -- MySQL Workbench Forward Engineering @@ -99,6 +99,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`permissions` ( `application_id` INT UNSIGNED NOT NULL, `name` VARCHAR(512) NOT NULL, `description` TEXT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`application_id` ASC, `name` ASC) VISIBLE, INDEX `fk_permissions_applications1_idx` (`application_id` ASC) VISIBLE, @@ -229,7 +231,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`companies` ( `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `disabled` TINYINT NOT NULL DEFAULT 0 COMMENT 'This field allows blocking publications based on business rules', - `disabled_at` VARCHAR(45) NULL, + `disabled_at` DATETIME NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB; @@ -247,8 +249,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`locations` ( `zipcode` VARCHAR(10) NOT NULL, `address_line1` VARCHAR(512) NOT NULL, `address_line2` VARCHAR(512) NULL, - `lat` VARCHAR(128) NULL, - `lng` VARCHAR(128) NULL, + `lat` DECIMAL(10,8) NULL, + `lng` DECIMAL(10,8) NULL, `name` VARCHAR(512) NULL, `description` TEXT NULL, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -272,7 +274,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`loads` ( `created_by` INT UNSIGNED NOT NULL, `origin_id` INT UNSIGNED NULL, `destination_id` INT UNSIGNED NULL, - `status` ENUM('Draft', 'Published', 'Completed', 'Closed', 'Cancel') NOT NULL DEFAULT 'Draft', + `status` ENUM('Draft', 'Published', 'Completed', 'Closed', 'Cancelled') NOT NULL DEFAULT 'Draft', `product` VARCHAR(100) NOT NULL COMMENT 'Maiz, Trigo, etc', `sector` VARCHAR(100) NOT NULL COMMENT 'Automotriz, Agricola, etc', `truck_type` VARCHAR(100) NOT NULL, @@ -322,6 +324,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicles` ( `company_id` INT UNSIGNED NOT NULL, `driver_id` INT UNSIGNED NULL, `load_id` INT UNSIGNED NULL, + `status` ENUM('Available', 'Busy') NOT NULL DEFAULT 'Available', `VIN` VARCHAR(45) NOT NULL, `truck_plate` VARCHAR(45) NOT NULL, `trailer_plate_1` VARCHAR(45) NULL, @@ -332,6 +335,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicles` ( INDEX `fk_vehicles_companies1_idx` (`company_id` ASC) VISIBLE, UNIQUE INDEX `driver_id_UNIQUE` (`driver_id` ASC) VISIBLE, UNIQUE INDEX `load_id_UNIQUE` (`load_id` ASC) VISIBLE, + UNIQUE INDEX `VIN_UNIQUE` (`company_id` ASC, `VIN` ASC) VISIBLE, + UNIQUE INDEX `truck_plate_UNIQUE` (`company_id` ASC, `truck_plate` ASC) VISIBLE, CONSTRAINT `fk_vehicles_companies1` FOREIGN KEY (`company_id`) REFERENCES `u947463964_etaviaporte`.`companies` (`id`) @@ -359,8 +364,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`load_shipments` ( `status` ENUM('Assigned', 'Loading', 'Transit', 'Unloading', 'Delivered') NOT NULL DEFAULT 'Assigned', `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `last_lat` VARCHAR(128) NULL, - `last_lng` VARCHAR(128) NULL, + `last_lat` DECIMAL(10,8) NULL, + `last_lng` DECIMAL(10,8) NULL, PRIMARY KEY (`id`), INDEX `fk_load_shipment_loads1_idx` (`load_id` ASC) VISIBLE, UNIQUE INDEX `load_id_UNIQUE` (`load_id` ASC) VISIBLE, @@ -405,22 +410,22 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`shipment_proposals` ( `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), INDEX `fk_shipment_proposals_loads1_idx` (`load_id` ASC) VISIBLE, - INDEX `fk_shipment_proposals_user_roles1_idx` (`created_by` ASC) VISIBLE, INDEX `fk_shipment_proposals_vehicles1_idx` (`vehicle_id` ASC) VISIBLE, + INDEX `fk_shipment_proposals_users1_idx` (`created_by` ASC) VISIBLE, CONSTRAINT `fk_shipment_proposals_loads1` FOREIGN KEY (`load_id`) REFERENCES `u947463964_etaviaporte`.`loads` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT `fk_shipment_proposals_user_roles1` - FOREIGN KEY (`created_by`) - REFERENCES `u947463964_etaviaporte`.`user_roles` (`id`) - ON DELETE CASCADE - ON UPDATE NO ACTION, CONSTRAINT `fk_shipment_proposals_vehicles1` FOREIGN KEY (`vehicle_id`) REFERENCES `u947463964_etaviaporte`.`vehicles` (`id`) ON DELETE SET NULL + ON UPDATE NO ACTION, + CONSTRAINT `fk_shipment_proposals_users1` + FOREIGN KEY (`created_by`) + REFERENCES `u947463964_etaviaporte`.`users` (`id`) + ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -438,8 +443,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`shipment_agreements` ( PRIMARY KEY (`id`), INDEX `fk_shipment_proposal_agreement_loads1_idx` (`load_id` ASC) VISIBLE, INDEX `fk_shipment_proposal_agreement_shipment_proposals1_idx` (`proposal_id` ASC) VISIBLE, - INDEX `fk_shipment_proposal_agreement_user_roles1_idx` (`accepted_by` ASC) VISIBLE, UNIQUE INDEX `load_id_UNIQUE` (`load_id` ASC) VISIBLE, + INDEX `fk_shipment_agreements_users1_idx` (`accepted_by` ASC) VISIBLE, CONSTRAINT `fk_shipment_proposal_agreement_loads1` FOREIGN KEY (`load_id`) REFERENCES `u947463964_etaviaporte`.`loads` (`id`) @@ -450,9 +455,9 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`shipment_agreements` ( REFERENCES `u947463964_etaviaporte`.`shipment_proposals` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, - CONSTRAINT `fk_shipment_proposal_agreement_user_roles1` + CONSTRAINT `fk_shipment_agreements_users1` FOREIGN KEY (`accepted_by`) - REFERENCES `u947463964_etaviaporte`.`user_roles` (`id`) + REFERENCES `u947463964_etaviaporte`.`users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -464,17 +469,21 @@ ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_sectors` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `sector` VARCHAR(100) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `sector_UNIQUE` (`sector` ASC) VISIBLE) ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `u947463964_etaviaporte`.`meta_truck_types` +-- Table `u947463964_etaviaporte`.`meta_vehicle_types` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_truck_types` ( +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_vehicle_types` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `type` VARCHAR(100) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `meta_truck_typescol_UNIQUE` (`type` ASC) VISIBLE) ENGINE = InnoDB; @@ -486,6 +495,8 @@ ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_products` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `product` VARCHAR(100) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `product_UNIQUE` (`product` ASC) VISIBLE) ENGINE = InnoDB; @@ -500,6 +511,8 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`meta_cities` ( `state` VARCHAR(100) NOT NULL, `country` VARCHAR(100) NOT NULL, `zipcode` VARCHAR(100) NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE = InnoDB; @@ -522,9 +535,9 @@ ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `u947463964_etaviaporte`.`company_truck_types` +-- Table `u947463964_etaviaporte`.`company_vehicle_types` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_truck_types` ( +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_vehicle_types` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `company_id` INT UNSIGNED NOT NULL, `truck_type` VARCHAR(100) NOT NULL, @@ -562,9 +575,9 @@ ENGINE = InnoDB; -- ----------------------------------------------------- --- Table `u947463964_etaviaporte`.`truck_types` +-- Table `u947463964_etaviaporte`.`vehicle_types` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`truck_types` ( +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicle_types` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `vehicle_id` INT UNSIGNED NOT NULL, `type_id` INT UNSIGNED NOT NULL, @@ -578,7 +591,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`truck_types` ( ON UPDATE NO ACTION, CONSTRAINT `fk_vehicle_types_company_truck_types1` FOREIGN KEY (`type_id`) - REFERENCES `u947463964_etaviaporte`.`company_truck_types` (`id`) + REFERENCES `u947463964_etaviaporte`.`company_vehicle_types` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -633,22 +646,22 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`load_templates` ( CONSTRAINT `fk_load_templates_companies1` FOREIGN KEY (`company_id`) REFERENCES `u947463964_etaviaporte`.`companies` (`id`) - ON DELETE NO ACTION + ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `fk_load_templates_locations1` FOREIGN KEY (`origin_id`) REFERENCES `u947463964_etaviaporte`.`locations` (`id`) - ON DELETE NO ACTION + ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT `fk_load_templates_locations2` FOREIGN KEY (`destination_id`) REFERENCES `u947463964_etaviaporte`.`locations` (`id`) - ON DELETE NO ACTION + ON DELETE SET NULL ON UPDATE NO ACTION, CONSTRAINT `fk_load_templates_users1` FOREIGN KEY (`created_by`) REFERENCES `u947463964_etaviaporte`.`users` (`id`) - ON DELETE NO ACTION + ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; @@ -684,7 +697,7 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_users` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT UNSIGNED NOT NULL, `company_id` INT UNSIGNED NOT NULL, - `created_at` DATETIME NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) VISIBLE, INDEX `fk_company_users_companies1_idx` (`company_id` ASC) VISIBLE, @@ -787,6 +800,133 @@ CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`warehouse_alert_emails` ( ENGINE = InnoDB; +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`company_status` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_status` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `company_id` INT UNSIGNED NOT NULL, + `status` ENUM('Registered', 'InReview', 'Enabled', 'Disabled') NOT NULL DEFAULT 'Registered', + `notes` TEXT NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_company_status_companies1_idx` (`company_id` ASC) VISIBLE, + UNIQUE INDEX `company_id_UNIQUE` (`company_id` ASC) VISIBLE, + CONSTRAINT `fk_company_status_companies1` + FOREIGN KEY (`company_id`) + REFERENCES `u947463964_etaviaporte`.`companies` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`company_documents` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`company_documents` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `company_id` INT UNSIGNED NOT NULL, + `document_id` VARCHAR(255) NOT NULL, + `name` VARCHAR(512) NOT NULL, + `status` ENUM('New', 'InReview', 'Approved', 'Rejected') NOT NULL DEFAULT 'New', + `status_notes` TEXT NOT NULL COMMENT 'Add metadata like user who reviewed and reason behind the status assigned', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_company_documents_companies1_idx` (`company_id` ASC) VISIBLE, + UNIQUE INDEX `name_UNIQUE` (`company_id` ASC, `name` ASC) VISIBLE, + CONSTRAINT `fk_company_documents_companies1` + FOREIGN KEY (`company_id`) + REFERENCES `u947463964_etaviaporte`.`companies` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`apikeys` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`apikeys` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `application_id` INT UNSIGNED NOT NULL, + `name` VARCHAR(512) NOT NULL, + `description` TEXT NULL, + `key_hash` VARCHAR(255) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `expires_at` DATETIME NULL, + PRIMARY KEY (`id`), + UNIQUE INDEX `key_hash_UNIQUE` (`key_hash` ASC) VISIBLE, + CONSTRAINT `fk_apikeys_applications1` + FOREIGN KEY (`application_id`) + REFERENCES `u947463964_etaviaporte`.`applications` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`apikey_permissions` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`apikey_permissions` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `application_id` INT UNSIGNED NOT NULL, + `permission_id` INT UNSIGNED NOT NULL, + `apikey_id` INT UNSIGNED NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_apikey_permissions_permissions1_idx` (`permission_id` ASC) VISIBLE, + INDEX `fk_apikey_permissions_apikeys1_idx` (`apikey_id` ASC) VISIBLE, + UNIQUE INDEX `apikey_id_UNIQUE` (`apikey_id` ASC, `permission_id` ASC) VISIBLE, + CONSTRAINT `fk_apikey_permissions_applications1` + FOREIGN KEY (`application_id`) + REFERENCES `u947463964_etaviaporte`.`applications` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_apikey_permissions_permissions1` + FOREIGN KEY (`permission_id`) + REFERENCES `u947463964_etaviaporte`.`permissions` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_apikey_permissions_apikeys1` + FOREIGN KEY (`apikey_id`) + REFERENCES `u947463964_etaviaporte`.`apikeys` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + +-- ----------------------------------------------------- +-- Table `u947463964_etaviaporte`.`vehicle_documents` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`vehicle_documents` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, + `company_id` INT UNSIGNED NOT NULL, + `vehicle_id` INT UNSIGNED NOT NULL, + `document_id` VARCHAR(255) NOT NULL, + `name` VARCHAR(512) NOT NULL, + `status` ENUM('New', 'InReview', 'Approved', 'Rejected') NOT NULL DEFAULT 'New', + `status_notes` TEXT NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + INDEX `fk_vehicle_documents_companies1_idx` (`company_id` ASC) VISIBLE, + INDEX `fk_vehicle_documents_vehicles1_idx` (`vehicle_id` ASC) VISIBLE, + UNIQUE INDEX `name_UNIQUE` (`company_id` ASC, `name` ASC) VISIBLE, + CONSTRAINT `fk_vehicle_documents_companies1` + FOREIGN KEY (`company_id`) + REFERENCES `u947463964_etaviaporte`.`companies` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION, + CONSTRAINT `fk_vehicle_documents_vehicles1` + FOREIGN KEY (`vehicle_id`) + REFERENCES `u947463964_etaviaporte`.`vehicles` (`id`) + ON DELETE CASCADE + ON UPDATE NO ACTION) +ENGINE = InnoDB; + + SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;