Commit a7e2e1dd0bf885af05ce22cec01d302b8c10e03a

Authored by David RENÉ
1 parent 53075ced

[+] add the generation of the file /generated/migration/to_current.anubis which …

…contain the read of the current generated model version. So to do the migration to the last version no need anymore to change the version number by hand like before.
hayamiki_generator.1.19.aproj
@@ -452,6 +452,7 @@ @@ -452,6 +452,7 @@
452 <Compile Include="src\generation\model.anubis" /> 452 <Compile Include="src\generation\model.anubis" />
453 <Compile Include="src\generation\SQL_get_all.anubis" /> 453 <Compile Include="src\generation\SQL_get_all.anubis" />
454 <Compile Include="src\generation\SQL_get_count.anubis" /> 454 <Compile Include="src\generation\SQL_get_count.anubis" />
  455 + <Compile Include="src\generation\to_current.anubis" />
455 <Compile Include="src\generation\types.anubis" /> 456 <Compile Include="src\generation\types.anubis" />
456 <Compile Include="src\generation\vt_edit.anubis" /> 457 <Compile Include="src\generation\vt_edit.anubis" />
457 <Compile Include="src\generation\vt_view.anubis" /> 458 <Compile Include="src\generation\vt_view.anubis" />
hayamiki_lib @ accc7490a42
1 -Subproject commit d169d6079aaa2b2a29f999b0047feb3d057f84b1 1 +Subproject commit accc7490a42d73a0666e87883bf9170dfd85be8b
src/app/app_version.anubis
@@ -11,7 +11,7 @@ read system/string.anubis @@ -11,7 +11,7 @@ read system/string.anubis
11 11
12 public define Int major = 1. 12 public define Int major = 1.
13 public define Int minor = 19. 13 public define Int minor = 19.
14 -public define Int release = 3. 14 +public define Int release = 4.
15 public define Int build = 0. 15 public define Int build = 0.
16 public define String status = "". 16 public define String status = "".
17 17
src/generation/create_table.anubis
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 * Date: 24/01/2016 4 * Date: 24/01/2016
5 * Time: 18:13 5 * Time: 18:13
6 6
7 -Hayamiki is Copyright © 2016-2020 by David RENÉ 7 +Hayamiki is Copyright © 2016-2023 by David RENÉ
8 All rights reserved. 8 All rights reserved.
9 9
10 Redistribution and use in source and binary forms, with or without modification, 10 Redistribution and use in source and binary forms, with or without modification,
@@ -320,8 +320,8 @@ public define Maybe(One) @@ -320,8 +320,8 @@ public define Maybe(One)
320 320
321 with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language 321 with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language
322 322
323 - with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis",  
324 - with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", 323 + with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis",
  324 + with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis",
325 //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis", 325 //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis",
326 //create all necessary directories if doesn't exist. 326 //create all necessary directories if doesn't exist.
327 make_directories(file_name); 327 make_directories(file_name);
@@ -395,7 +395,7 @@ public define DB_Version db_model_version = db_version(\&quot;&quot;+version+&quot;\&quot;, \&quot;&quot;+_sha @@ -395,7 +395,7 @@ public define DB_Version db_model_version = db_version(\&quot;&quot;+version+&quot;\&quot;, \&quot;&quot;+_sha
395 failure then println("can't create file "+file_name);failure, 395 failure then println("can't create file "+file_name);failure,
396 success(fd) then 396 success(fd) then
397 with stream = make_stream(fd), 397 with stream = make_stream(fd),
398 - write_string(stream, 398 + write_string(stream,
399 "/* 399 "/*
400 * Created by 早見木 (Hayamiki). 400 * Created by 早見木 (Hayamiki).
401 * Date: "+_Int_to_ISO_8601_date(now)+" 401 * Date: "+_Int_to_ISO_8601_date(now)+"
@@ -483,5 +483,5 @@ global define VTM @@ -483,5 +483,5 @@ global define VTM
483 ) 483 )
484 . 484 .
485 ") 485 ")
486 - }}}  
487 - . 486 + }}}
  487 +.
src/generation/files.anubis
@@ -24,6 +24,7 @@ read generation/types.anubis @@ -24,6 +24,7 @@ read generation/types.anubis
24 read generation/densaku.anubis 24 read generation/densaku.anubis
25 read generation/extractor.anubis 25 read generation/extractor.anubis
26 read generation/create_table.anubis 26 read generation/create_table.anubis
  27 +read generation/to_current.anubis
27 read generation/hk_menu.anubis 28 read generation/hk_menu.anubis
28 read generation/cxm_lib_menu.anubis 29 read generation/cxm_lib_menu.anubis
29 read generation/fn_delete.anubis 30 read generation/fn_delete.anubis
@@ -287,9 +288,11 @@ define Maybe(One) @@ -287,9 +288,11 @@ define Maybe(One)
287 make_vtm(apps, destination_dir); 288 make_vtm(apps, destination_dir);
288 println("Generating create for Database "+name); 289 println("Generating create for Database "+name);
289 if generate_create_table(app_name, apps, destination_dir, version, current_db_SHA1) is failure then println("failure");failure else 290 if generate_create_table(app_name, apps, destination_dir, version, current_db_SHA1) is failure then println("failure");failure else
290 - println("Generating menu for Database "+name);  
291 - if generate_hk_menus(apps, destination_dir) is failure then println("failure");failure else  
292 - if generate_cxm_lib_menus(apps, destination_dir) is failure then println("failure");failure else 291 + println("Generating to current version file");
  292 + if generate_to_current_file(destination_dir, version) is failure then println("can't create to_current file"); failure else
  293 + println("Generating menu for Database "+name);
  294 + if generate_hk_menus(apps, destination_dir) is failure then println("failure");failure else
  295 + if generate_cxm_lib_menus(apps, destination_dir) is failure then println("failure");failure else
293 writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1); 296 writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1);
294 writeString(ini, "DB_MODEL", "Version", version); 297 writeString(ini, "DB_MODEL", "Version", version);
295 writeString(ini, "HK_GENERATOR", "Generator_version", product_numerical_version); 298 writeString(ini, "HK_GENERATOR", "Generator_version", product_numerical_version);
src/generation/to_current.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 22/01/2023
  5 + * Time: 19:42
  6 + * © David RENÉ
  7 + *
  8 +Hayamiki is Copyright © 2016-2023 by David RENÉ
  9 +All rights reserved.
  10 +
  11 +Redistribution and use in source and binary forms, with or without modification,
  12 +are permitted provided that the following conditions are met:
  13 +
  14 +1. Redistributions of source code must retain the above copyright notice,
  15 + this list of conditions and the following disclaimer.
  16 +
  17 +2. Redistributions in binary form must reproduce the above copyright notice,
  18 + this list of conditions and the following disclaimer in the documentation
  19 + and/or other materials provided with the distribution.
  20 +
  21 +THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
  22 +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23 +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24 +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  25 +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30 +POSSIBILITY OF SUCH DAMAGE.
  31 + */
  32 +
  33 +read system/string.anubis
  34 +read tools/streams.anubis
  35 +read tools/basis.anubis
  36 +read tools/ISO-8601.anubis
  37 +
  38 +public define Maybe(One)
  39 + generate_to_current_file
  40 + (
  41 + String dest_dir,
  42 + String version,
  43 + )=
  44 +
  45 + with to_current_file_name = dest_dir+"database/generated/migration/to_current.anubis",
  46 +
  47 + //create file with current database version
  48 + if file(to_current_file_name, new) is
  49 + {
  50 + failure then println("can't create file "+to_current_file_name);failure,
  51 + success(fd_cfn) then
  52 + with stream_cfn = make_stream(fd_cfn),
  53 + write_string(stream_cfn,
  54 +"/*
  55 + * Created by 早見木 (Hayamiki).
  56 + * Date: "+_Int_to_ISO_8601_date(now)+"
  57 + * Time: "+_Int_to_ISO_8601_time(now)+"
  58 + */
  59 + *
  60 +read database/generated/migration/to_"+version+".anubis
  61 +"
  62 +)
  63 + }
  64 +.
  65 +