2017-05-09 27 views
1

我有一些现有的基于Java的网络应用程序,并且我希望它能够制作Phoenix版本的那些应用程序。使用种子或迁移exs创建存储过程

我现有的一些存储过程很多。我如何使用迁移或种子exs来创建这些存储过程?任何线索?

谢谢

+0

有一个关于播种数据指导也许这可以帮助:http://www.phoenixframework.org/docs/seeding-data –

回答

2

我会在迁移中做到这一点。您应该实现up函数中的创建以及down函数中的删除。在迁移中使用execute命令来运行任意sql。

def up do 
    execute "INSERT INTO add_col_migration (value, to_be_added) VALUES (1, 2)" 
end 

def down do 
    execute "..." 
end 

请参阅该文档https://hexdocs.pm/ecto/Ecto.Migration.html#execute/1