DRYな備忘録

Don't Repeat Yourself.

2016-02-16から1日間の記事一覧

【Elixir】Ecto.Migrationで外部キー参照とNOT NULL制約を追加

こういうことを学んだので↓ otiai10.hatenablog.com これを、Ecto.Migrationでやりたい defmodule MyApp.Repo.Migrations.CreateUserToken do use Ecto.Migration def change do create table(:posts) do add :user_id, references(:users, on_delete: :dele…

【MySQL】DEFAULT NULLと外部キー制約の同居

同居できるんかなと(ほんとはMariaDB) mysql> CREATE TABLE users ( id SERIAL, name VARCHAR(255) ); Query OK, 0 rows affected (0.01 sec) mysql> CREATE TABLE posts ( user_id BIGINT(20) UNSIGNED DEFAULT NULL, # ← あえてつける message VARCHAR(2…

【Elixir】Module内のfunctionのリストを取得する

stackoverflow.com Ecto.Repo.__info__(:functions) [__adapter__: 0, __pool__: 0, __query_cache__: 0, __repo__: 0, all: 1, all: 2, config: 0, delete: 1, delete: 2, delete!: 1, delete!: 2, delete_all: 1, delete_all: 2, get: 2, get: 3, get!: 2,…

Ecto.Migration内でINSERTする

Ecto.Migration – Ecto v2.0.0-beta.0 execute使お... defmodule MyApp.Repo.Migrations.CreateProviderTable do use Ecto.Migration def change do create table(:providers) do add :name, :string timestamps end create unique_index(:providers, [:name…