add migration
All checks were successful
Build and Publish / build-release (push) Successful in 1m20s
All checks were successful
Build and Publish / build-release (push) Successful in 1m20s
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
name = "customer_service";
|
||||
contents = [ package pkgs.bashInteractive pkgs.busybox pkgs.shadow ];
|
||||
config = {
|
||||
Cmd = [ "${package}/bin/customer_service" "start" ];
|
||||
Cmd = [ "${package}/bin/customer_service" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
30
lib/customer_service/release.ex
Normal file
30
lib/customer_service/release.ex
Normal file
@@ -0,0 +1,30 @@
|
||||
defmodule CustomerService.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :customer_service
|
||||
|
||||
def migrate do
|
||||
load_app()
|
||||
|
||||
for repo <- repos() do
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||
end
|
||||
end
|
||||
|
||||
def rollback(repo, version) do
|
||||
load_app()
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
||||
defp load_app do
|
||||
# Many platforms require SSL when connecting to the database
|
||||
Application.ensure_all_started(:ssl)
|
||||
Application.ensure_loaded(@app)
|
||||
end
|
||||
end
|
||||
@@ -3,11 +3,29 @@ controllers:
|
||||
enabled: true
|
||||
type: deployment
|
||||
replicas: 1
|
||||
|
||||
initContainers:
|
||||
migrate:
|
||||
image:
|
||||
repository: gitea.corredorconect.com/software-engineering/customer-service
|
||||
tag: '{{ $.Chart.AppVersion }}'
|
||||
args:
|
||||
- "eval"
|
||||
- "CustomService.Release.migrate"
|
||||
env:
|
||||
MIX_ENV: prod
|
||||
DATABASE_URL:
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: policy-service-pg-app
|
||||
key: uri
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
repository: gitea.corredorconect.com/software-engineering/customer-service
|
||||
tag: '{{ $.Chart.AppVersion }}'
|
||||
args:
|
||||
- "start"
|
||||
env:
|
||||
LOG_LEVEL: info
|
||||
MIX_ENV: prod
|
||||
|
||||
5
rel/overlays/bin/migrate
Executable file
5
rel/overlays/bin/migrate
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
exec ./customer_service eval CustomerService.Release.migrate
|
||||
1
rel/overlays/bin/migrate.bat
Executable file
1
rel/overlays/bin/migrate.bat
Executable file
@@ -0,0 +1 @@
|
||||
call "%~dp0\customer_service" eval CustomerService.Release.migrate
|
||||
5
rel/overlays/bin/server
Executable file
5
rel/overlays/bin/server
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd -P -- "$(dirname -- "$0")"
|
||||
PHX_SERVER=true exec ./customer_service start
|
||||
2
rel/overlays/bin/server.bat
Executable file
2
rel/overlays/bin/server.bat
Executable file
@@ -0,0 +1,2 @@
|
||||
set PHX_SERVER=true
|
||||
call "%~dp0\customer_service" start
|
||||
Reference in New Issue
Block a user