使用数据操作的Laravel Migration

时间:2017-11-17 00:32:53

标签: php mysql laravel laravel-5 migration

我有一个包含3个需要迁移的表的数据库:

processes:包含有关流程的数据

process_id - Id of the process
step_1_data - data about step 1
step_2_data - data about step 2
step_3_data - data about step 3

file_process:与该流程的文件有多对多的关系

process_id - required foreign key to process
file_id - required foreign key to file
file_label - label of the file step

files:是一个通用文件表

file_id - Id of the file
name - name of the file
... lots of other file data

这就是我想要的:

processes:包含有关流程的数据

process_id - Id of the process

steps:与该流程的文件有多对多的关系

step_id - Id of the step
process_id - required foreign key to process
name - the name of the step (from column of step 1, 2, 3, and file_label)
data - data about step 1, 2, 3 (in different records)
file_id - nullable foreign key to file

files:是一个通用文件表(保持不变)

file_id - Id of the file
name - name of the file
... lots of other file data

我可以进行迁移,将步骤表更改为包含步骤信息的通用步骤表。但是,我需要对当前流程记录进行一次性迁移,以便根据流程在......流程中的位置创建步骤记录:P

原始数据库查询似乎不是一个好选择,因为我需要根据他们所处的阶段做不同的事情。

在Laravel中进行迁移同时包含数据操作和模式操作的最佳方法是什么?

0 个答案:

没有答案