rename to memex
This commit is contained in:
		
							
								
								
									
										22
									
								
								lib/memex/repo/migrator.ex
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								lib/memex/repo/migrator.ex
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| defmodule Memex.Repo.Migrator do | ||||
|   @moduledoc """ | ||||
|   Genserver to automatically perform all migration on app start | ||||
|   """ | ||||
|  | ||||
|   use GenServer | ||||
|   require Logger | ||||
|  | ||||
|   def start_link(_) do | ||||
|     GenServer.start_link(__MODULE__, [], []) | ||||
|   end | ||||
|  | ||||
|   def init(_) do | ||||
|     migrate!() | ||||
|     {:ok, nil} | ||||
|   end | ||||
|  | ||||
|   def migrate! do | ||||
|     path = Application.app_dir(:memex, "priv/repo/migrations") | ||||
|     Ecto.Migrator.run(Memex.Repo, path, :up, all: true) | ||||
|   end | ||||
| end | ||||
		Reference in New Issue
	
	Block a user