From a7e2e1dd0bf885af05ce22cec01d302b8c10e03a Mon Sep 17 00:00:00 2001 From: totoro Date: Mon, 13 Mar 2023 14:47:30 +0100 Subject: [PATCH] [+] 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 | 1 + hayamiki_lib | 2 +- src/app/app_version.anubis | 2 +- src/generation/create_table.anubis | 12 ++++++------ src/generation/files.anubis | 9 ++++++--- src/generation/to_current.anubis | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 src/generation/to_current.anubis diff --git a/hayamiki_generator.1.19.aproj b/hayamiki_generator.1.19.aproj index b1d1e51..bc4b06e 100644 --- a/hayamiki_generator.1.19.aproj +++ b/hayamiki_generator.1.19.aproj @@ -452,6 +452,7 @@ + diff --git a/hayamiki_lib b/hayamiki_lib index d169d60..accc749 160000 --- a/hayamiki_lib +++ b/hayamiki_lib @@ -1 +1 @@ -Subproject commit d169d6079aaa2b2a29f999b0047feb3d057f84b1 +Subproject commit accc7490a42d73a0666e87883bf9170dfd85be8b diff --git a/src/app/app_version.anubis b/src/app/app_version.anubis index 810a043..a4475a9 100644 --- a/src/app/app_version.anubis +++ b/src/app/app_version.anubis @@ -11,7 +11,7 @@ read system/string.anubis public define Int major = 1. public define Int minor = 19. -public define Int release = 3. +public define Int release = 4. public define Int build = 0. public define String status = "". diff --git a/src/generation/create_table.anubis b/src/generation/create_table.anubis index 6ef8ae5..70fb680 100644 --- a/src/generation/create_table.anubis +++ b/src/generation/create_table.anubis @@ -4,7 +4,7 @@ * Date: 24/01/2016 * Time: 18:13 -Hayamiki is Copyright © 2016-2020 by David RENÉ +Hayamiki is Copyright © 2016-2023 by David RENÉ All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -320,8 +320,8 @@ public define Maybe(One) with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language - with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", - with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", + with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis", + with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis", //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis", //create all necessary directories if doesn't exist. make_directories(file_name); @@ -395,7 +395,7 @@ public define DB_Version db_model_version = db_version(\""+version+"\", \""+_sha failure then println("can't create file "+file_name);failure, success(fd) then with stream = make_stream(fd), - write_string(stream, + write_string(stream, "/* * Created by 早見木 (Hayamiki). * Date: "+_Int_to_ISO_8601_date(now)+" @@ -483,5 +483,5 @@ global define VTM ) . ") - }}} - . + }}} +. diff --git a/src/generation/files.anubis b/src/generation/files.anubis index 2e5dc95..e2b485b 100644 --- a/src/generation/files.anubis +++ b/src/generation/files.anubis @@ -24,6 +24,7 @@ read generation/types.anubis read generation/densaku.anubis read generation/extractor.anubis read generation/create_table.anubis +read generation/to_current.anubis read generation/hk_menu.anubis read generation/cxm_lib_menu.anubis read generation/fn_delete.anubis @@ -287,9 +288,11 @@ define Maybe(One) make_vtm(apps, destination_dir); println("Generating create for Database "+name); if generate_create_table(app_name, apps, destination_dir, version, current_db_SHA1) is failure then println("failure");failure else - println("Generating menu for Database "+name); - if generate_hk_menus(apps, destination_dir) is failure then println("failure");failure else - if generate_cxm_lib_menus(apps, destination_dir) is failure then println("failure");failure else + println("Generating to current version file"); + if generate_to_current_file(destination_dir, version) is failure then println("can't create to_current file"); failure else + println("Generating menu for Database "+name); + if generate_hk_menus(apps, destination_dir) is failure then println("failure");failure else + if generate_cxm_lib_menus(apps, destination_dir) is failure then println("failure");failure else writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1); writeString(ini, "DB_MODEL", "Version", version); writeString(ini, "HK_GENERATOR", "Generator_version", product_numerical_version); diff --git a/src/generation/to_current.anubis b/src/generation/to_current.anubis new file mode 100644 index 0000000..3188eff --- /dev/null +++ b/src/generation/to_current.anubis @@ -0,0 +1,65 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 22/01/2023 + * Time: 19:42 + * © David RENÉ + * +Hayamiki is Copyright © 2016-2023 by David RENÉ +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + */ + +read system/string.anubis +read tools/streams.anubis +read tools/basis.anubis +read tools/ISO-8601.anubis + +public define Maybe(One) + generate_to_current_file + ( + String dest_dir, + String version, + )= + + with to_current_file_name = dest_dir+"database/generated/migration/to_current.anubis", + + //create file with current database version + if file(to_current_file_name, new) is + { + failure then println("can't create file "+to_current_file_name);failure, + success(fd_cfn) then + with stream_cfn = make_stream(fd_cfn), + write_string(stream_cfn, +"/* + * Created by 早見木 (Hayamiki). + * Date: "+_Int_to_ISO_8601_date(now)+" + * Time: "+_Int_to_ISO_8601_time(now)+" + */ + * +read database/generated/migration/to_"+version+".anubis +" +) + } +. + -- libgit2 0.21.4