mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-04 05:09:48 +08:00
This commit is contained in:
parent
04aa125ba2
commit
3030419ee1
@ -14,3 +14,37 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
-- alter table `t_ds_worker_group` add `description` varchar(256);
|
||||||
|
drop procedure if exists add_column_safety;
|
||||||
|
delimiter d//
|
||||||
|
create procedure add_column_safety(target_table_name varchar(256), target_column varchar(256),
|
||||||
|
target_column_type varchar(256), sths_else varchar(256))
|
||||||
|
begin
|
||||||
|
declare target_database varchar(256);
|
||||||
|
select database() into target_database;
|
||||||
|
IF EXISTS(SELECT *
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE COLUMN_NAME = target_column
|
||||||
|
AND TABLE_NAME = target_table_name
|
||||||
|
)
|
||||||
|
THEN
|
||||||
|
set @statement =
|
||||||
|
concat('alter table ', target_table_name, ' change column ', target_column, ' ', target_column, ' ',
|
||||||
|
target_column_type, ' ',
|
||||||
|
sths_else);
|
||||||
|
PREPARE STMT_c FROM @statement;
|
||||||
|
EXECUTE STMT_c;
|
||||||
|
ELSE
|
||||||
|
set @statement =
|
||||||
|
concat('alter table ', target_table_name, ' add column ', target_column, ' ', target_column_type, ' ',
|
||||||
|
sths_else);
|
||||||
|
PREPARE STMT_a FROM @statement;
|
||||||
|
EXECUTE STMT_a;
|
||||||
|
END IF;
|
||||||
|
end;
|
||||||
|
d//
|
||||||
|
delimiter ;
|
||||||
|
|
||||||
|
-- ALTER TABLE t_ds_worker_group ADD COLUMN description varchar(255) DEFAULT NULL COMMENT 'ds worker group description';
|
||||||
|
call add_column_safety('t_ds_worker_group','description', 'varchar(255)' , "DEFAULT NULL COMMENT 'ds worker group description'");
|
||||||
|
drop procedure if exists add_column_safety;
|
@ -14,3 +14,5 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
--- add column
|
||||||
|
ALTER TABLE t_ds_task_group alter COLUMN description type varchar(255);
|
Loading…
Reference in New Issue
Block a user