diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2016-01-31 18:56:59 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2016-01-31 19:03:09 +0100 |
commit | 33c3da3d19ceadeda013491acc98d9971a3a2fa1 (patch) | |
tree | 09a957a90a2c05ba9a7d8c2cb236ecb597ee84a8 /add_extbase_property.sh | |
parent | 34a5338a1f10d8d066cb20eda431c7ea54e1d29c (diff) | |
download | extbase-generator-cli-33c3da3d19ceadeda013491acc98d9971a3a2fa1.tar.gz extbase-generator-cli-33c3da3d19ceadeda013491acc98d9971a3a2fa1.tar.bz2 extbase-generator-cli-33c3da3d19ceadeda013491acc98d9971a3a2fa1.zip |
property: Optimize positioning in ext_tables.sql
Put the new field before tstamp (i.e after the last added property)
like a human would do.
Diffstat (limited to 'add_extbase_property.sh')
-rwxr-xr-x | add_extbase_property.sh | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/add_extbase_property.sh b/add_extbase_property.sh index 664a742..5f7aac4 100755 --- a/add_extbase_property.sh +++ b/add_extbase_property.sh @@ -217,10 +217,29 @@ sed -i "s/.*<\/body>/\t\t\t<trans-unit id=\"${field}.description\">\n\t\t\t\t<so Resources/Private/Language/locallang_csh_${tablename}.xlf -#ext_tables.sql -sed -i "s/CREATE TABLE ${tablename} (/&\n\n\t${field} ${sql_type},/" ext_tables.sql +# Try to place the new field before tstamp (or if that fails directly after the CREATE TABLE statement) +sed -i -f - ext_tables.sql << EOF +/^CREATE TABLE tx_extensionbuildertext_domain_model_foo (/ { + # Fill up the current buffer with the following lines until we find the trailing ');' + :loop + /);/! { + N + b loop + } + + # This implies tstamp to be the first non-model field + # and that model fields and tstamp are seperated by two newlines + # (that is the case for extension_builder generated files and our generator) + s/\n\n[ \t]*tstamp /\n\t${field} ${sql_type},&/ + + # skip the following CREATE TABLE replace if we've already added + tend + + s/CREATE TABLE[^\n(]*([^\n]*\n/&\t${field} ${sql_type},\n/ + :end +} +EOF -#if grep --quient function sed -i "\$s#^#\n\ /**\n\ |