Spring-boot can create a table directly from the SQL file by simply configuring it. However, the file defaults to ";" As a conclusion, a stored procedure is required in the modification of the table structure. A ";" is required in the stored procedure. An execution error will occur. Good pit!
Solution:
Add the configuration of the end symbol to change the SQL execution of Spring-boot, and later at the end of the SQL file is "$$"
spring.datasource.separator=$$
SQL file, the function verifies that the table has a field and creates the field if it does not exist.
/*charge Audit-Main Table add field*/Drop procedure if existsadd_col_homework$$Create procedureAdd_col_homework ()BEGINIF not EXISTS(SELECTcolumn_name fromInformation_schema.columnsWHEREtable_name= 'chargeopaudition' andcolumn_name= 'remarks') Then ALTER TABLE' Chargeopaudition 'ADD COLUMN' Remarks 'varchar( -)CHARACTER SETUTF8 COLLATE utf8_general_ciNULL DEFAULT NULL ;END IF; IF not EXISTS(SELECTcolumn_name fromInformation_schema. COLUMNSWHEREcolumn_name='Transactionidstart' andtable_name='chargeopaudition' andTable_schema='ztev_db') Then ALTER TABLE' Chargeopaudition 'ADD COLUMN' Transactionidstart 'varchar( -)DEFAULT NULLCOMMENT'Start Trading Number' ; END IF; IF not EXISTS(SELECTcolumn_name fromInformation_schema. COLUMNSWHEREcolumn_name=' State' andtable_name='chargeopaudition' andTable_schema='ztev_db') Then ALTER TABLE' Chargeopaudition 'ADD COLUMN' State 'int(2)DEFAULT '1'COMMENT'1: Not reviewed, 2: Reviewed' ; END IF; IF not EXISTS(SELECTcolumn_name fromInformation_schema. COLUMNSWHEREcolumn_name='Transactionidend' andtable_name='chargeopaudition' andTable_schema='ztev_db') Then ALTER TABLE' Chargeopaudition 'ADD COLUMN' Transactionidend 'varchar( -)DEFAULT NULLCOMMENT'End Transaction Number' ; END IF;END$ $CALL add_col_homework () $$Drop procedure if existsadd_col_homework$$
Often write blogs, as notes
Spring-boot to perform a modified table structure in the Startup run script