2017-05-09 35 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