mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
fix(be): schedule migration
This commit is contained in:
parent
0b5998274d
commit
ebbea98248
@ -25,7 +25,7 @@ var tablesShouldBeTruncated = [...]string {
|
||||
"project__inventory",
|
||||
"project__repository",
|
||||
"project__template",
|
||||
"project__template_schedule",
|
||||
"project__schedule",
|
||||
"project__user",
|
||||
"user",
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
alter table project__template_schedule rename to project__schedule;
|
||||
alter table `project__schedule` add `id` integer primary key autoincrement;
|
||||
alter table `project__schedule` add `project_id` int not null references project(`id`);
|
||||
drop table project__template_schedule;
|
||||
|
||||
create table `project__schedule`
|
||||
(
|
||||
`id` integer primary key autoincrement,
|
||||
`template_id` int references project__template (`id`) on delete cascade,
|
||||
`project_id` int not null references project (`id`) on delete cascade,
|
||||
`cron_format` varchar(255) not null
|
||||
);
|
||||
|
@ -53,13 +53,13 @@ func (d *SqlDb) DeleteSchedule(projectID int, scheduleID int) error {
|
||||
}
|
||||
|
||||
func (d *SqlDb) GetSchedules() (schedules []db.Schedule, err error) {
|
||||
_, err = d.selectAll(&schedules, "select * from project__template_schedule where cron_format != ''")
|
||||
_, err = d.selectAll(&schedules, "select * from project__schedule where cron_format != ''")
|
||||
return
|
||||
}
|
||||
|
||||
func (d *SqlDb) GetTemplateSchedules(projectID int, templateID int) (schedules []db.Schedule, err error) {
|
||||
_, err = d.selectAll(&schedules,
|
||||
"select * from project__template_schedule where project_id=? and template_id=?",
|
||||
"select * from project__schedule where project_id=? and template_id=?",
|
||||
projectID,
|
||||
templateID)
|
||||
return
|
||||
|
@ -55,20 +55,20 @@ func (d *SqlDb) UpdateTemplate(template db.Template) error {
|
||||
//
|
||||
//if template.CronFormat == "" {
|
||||
// _, err = d.exec(
|
||||
// "delete from project__template_schedule where project_id =? and template_id=?",
|
||||
// "delete from project__schedule where project_id =? and template_id=?",
|
||||
// template.ProjectID,
|
||||
// template.ID)
|
||||
//} else {
|
||||
// _, err = d.GetTemplateSchedules(template.ProjectID, template.ID)
|
||||
// if err == nil {
|
||||
// _, err = d.exec(
|
||||
// "update project__template_schedule set cron_format=? where project_id =? and template_id=?",
|
||||
// "update project__schedule set cron_format=? where project_id =? and template_id=?",
|
||||
// template.CronFormat,
|
||||
// template.ProjectID,
|
||||
// template.ID)
|
||||
// } else if err == db.ErrNotFound {
|
||||
// _, err = d.exec(
|
||||
// "insert into project__template_schedule (template_id, cron_format) values (?, ?)",
|
||||
// "insert into project__schedule (template_id, cron_format) values (?, ?)",
|
||||
// template.ID,
|
||||
// template.CronFormat)
|
||||
// }
|
||||
|
Loading…
Reference in New Issue
Block a user