This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_soft_delete_cascade_function() do | |
execute( | |
""" | |
CREATE OR REPLACE FUNCTION soft_delete_cascade() RETURNS trigger AS $$ | |
DECLARE | |
ref RECORD; | |
BEGIN | |
IF EXISTS (SELECT true FROM new_table WHERE deleted_at IS NOT NULL) THEN | |
FOR ref IN | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_web_app_init_data(tg_init_data, bot_api_token) do | |
{received_hash, decoded_map} = | |
tg_init_data | |
|> URI.decode_query() | |
|> Map.pop!("hash") | |
data_check_string = | |
decoded_map | |
|> Enum.sort(fn {k1, _v1}, {k2, _v2} -> k1 <= k2 end) | |
|> Enum.map_join("\n", fn {k, v} -> "#{k}=#{v}" end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Migration do | |
@moduledoc """ | |
Additional helpers for PostgreSQL. | |
""" | |
import Ecto.Migration, only: [execute: 2] | |
defmacro __using__(_) do | |
quote do | |
use Ecto.Migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Factory do | |
use ExUnitProperties | |
alias MyApp.{Repo, User, Comment} | |
### Generators | |
def generator(:user) do | |
gen all name <- string(:alphanumeric, min_length: 2), | |
email <- generator(:email), | |
age <- integer(10..130) do |