# _Migration

name: watch-20200114110433
status: MigrationSuccess
errors: []
datamodel:
  enum Tree {
    ARBORVITAE
    YELLOWBIRCH
    BLACKASH
    DOUGLASFIR
    OAK
  }

  enum Permission {
    ADMIN
    USER
    OWNER
    COLLABORATOR
  }

  datasource my_db {
    provider = "sqlite"
    url      = "file:dev.db"
  }

  model User {
    id           String     @id @default(cuid())
    name         String
    email        String     @unique
    status       String
    permissions  Permission
    favoriteTree Tree
    location     Location?
    posts        Post[]
  }

  model Post {
    id        String   @id @default(cuid())
    name      String
    email     String   @unique
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
  }

  model Location {
    id   Int    @id
    city String
  }

datamodel_steps:
  [{"tag":"CreateEnum","enum":"Tree","values":["ARBORVITAE","YELLOWBIRCH","BLACKASH","DOUGLASFIR","OAK"]},{"tag":"CreateEnum","enum":"Permission","values":["ADMIN","USER","OWNER","COLLABORATOR"]},{"tag":"CreateSource","source":"my_db"},{"tag":"CreateArgument","location":{"tag":"Source","source":"my_db"},"argument":"provider","value":"\"sqlite\""},{"tag":"CreateArgument","location":{"tag":"Source","source":"my_db"},"argument":"url","value":"\"file:dev.db\""},{"tag":"CreateModel","model":"User"},{"tag":"CreateField","model":"User","field":"id","type":"String","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"User","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"User","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"User","field":"id"},"directive":"default"},"argument":"","value":"cuid()"},{"tag":"CreateField","model":"User","field":"name","type":"String","arity":"Required"},{"tag":"CreateField","model":"User","field":"email","type":"String","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"User","field":"email"},"directive":"unique"}},{"tag":"CreateField","model":"User","field":"status","type":"String","arity":"Required"},{"tag":"CreateField","model":"User","field":"permissions","type":"Permission","arity":"Required"},{"tag":"CreateField","model":"User","field":"favoriteTree","type":"Tree","arity":"Required"},{"tag":"CreateField","model":"User","field":"location","type":"Location","arity":"Optional"},{"tag":"CreateField","model":"User","field":"posts","type":"Post","arity":"List"},{"tag":"CreateModel","model":"Post"},{"tag":"CreateField","model":"Post","field":"id","type":"String","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Post","field":"id"},"directive":"default"},"argument":"","value":"cuid()"},{"tag":"CreateField","model":"Post","field":"name","type":"String","arity":"Required"},{"tag":"CreateField","model":"Post","field":"email","type":"String","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"email"},"directive":"unique"}},{"tag":"CreateField","model":"Post","field":"createdAt","type":"DateTime","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"createdAt"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Post","field":"createdAt"},"directive":"default"},"argument":"","value":"now()"},{"tag":"CreateField","model":"Post","field":"updatedAt","type":"DateTime","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"updatedAt"},"directive":"updatedAt"}},{"tag":"CreateModel","model":"Location"},{"tag":"CreateField","model":"Location","field":"id","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Location","field":"id"},"directive":"id"}},{"tag":"CreateField","model":"Location","field":"city","type":"String","arity":"Required"}]

database_migration:
  {"before":{"tables":[{"name":"_Migration","columns":[{"name":"applied","tpe":{"raw":"INTEGER","family":"int","arity":"required"},"default":null,"autoIncrement":false},{"name":"database_migration","tpe":{"raw":"TEXT","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"datamodel","tpe":{"raw":"TEXT","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"datamodel_steps","tpe":{"raw":"TEXT","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"errors","tpe":{"raw":"TEXT","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"finished_at","tpe":{"raw":"DATE","family":"dateTime","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"TEXT","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"revision","tpe":{"raw":"INTEGER","family":"int","arity":"required"},"default":null,"autoIncrement":true},{"name":"rolled_back","tpe":{"raw":"INTEGER","family":"int","arity":"required"},"default":null,"autoIncrement":false},{"name":"started_at","tpe":{"raw":"DATE","family":"dateTime","arity":"required"},"default":null,"autoIncrement":false},{"name":"status","tpe":{"raw":"TEXT","family":"string","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["revision"],"sequence":null},"foreignKeys":[]}],"enums":[],"sequences":[]},"after":{"tables":[{"name":"User","columns":[{"name":"email","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"favoriteTree","tpe":{"raw":"","family":"string","arity":"required"},"default":"ARBORVITAE","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"location","tpe":{"raw":"","family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"permissions","tpe":{"raw":"","family":"string","arity":"required"},"default":"ADMIN","autoIncrement":false},{"name":"status","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["location"],"referencedTable":"Location","referencedColumns":["id"],"onDeleteAction":"setNull"}]},{"name":"Post","columns":[{"name":"createdAt","tpe":{"raw":"","family":"dateTime","arity":"required"},"default":"1970-01-01 00:00:00","autoIncrement":false},{"name":"email","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"updatedAt","tpe":{"raw":"","family":"dateTime","arity":"required"},"default":"1970-01-01 00:00:00","autoIncrement":false},{"name":"user","tpe":{"raw":"","family":"string","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[{"name":"Post.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["user"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]},{"name":"Location","columns":[{"name":"city","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"int","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}],"enums":[],"sequences":[]},"original_steps":[{"CreateTable":{"table":{"name":"User","columns":[{"name":"email","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"favoriteTree","tpe":{"raw":"","family":"string","arity":"required"},"default":"ARBORVITAE","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"location","tpe":{"raw":"","family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"permissions","tpe":{"raw":"","family":"string","arity":"required"},"default":"ADMIN","autoIncrement":false},{"name":"status","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["location"],"referencedTable":"Location","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateTable":{"table":{"name":"Post","columns":[{"name":"createdAt","tpe":{"raw":"","family":"dateTime","arity":"required"},"default":"1970-01-01 00:00:00","autoIncrement":false},{"name":"email","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"updatedAt","tpe":{"raw":"","family":"dateTime","arity":"required"},"default":"1970-01-01 00:00:00","autoIncrement":false},{"name":"user","tpe":{"raw":"","family":"string","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[{"name":"Post.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["user"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateTable":{"table":{"name":"Location","columns":[{"name":"city","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"int","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}}},{"CreateIndex":{"table":"User","index":{"name":"User.email","columns":["email"],"tpe":"unique"}}},{"CreateIndex":{"table":"Post","index":{"name":"Post.email","columns":["email"],"tpe":"unique"}}},{"AddForeignKey":{"table":"User","foreign_key":{"constraintName":null,"columns":["location"],"referencedTable":"Location","referencedColumns":["id"],"onDeleteAction":"setNull"}}},{"AddForeignKey":{"table":"Post","foreign_key":{"constraintName":null,"columns":["user"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}}}],"corrected_steps":[{"CreateTable":{"table":{"name":"User","columns":[{"name":"email","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"favoriteTree","tpe":{"raw":"","family":"string","arity":"required"},"default":"ARBORVITAE","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"location","tpe":{"raw":"","family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"permissions","tpe":{"raw":"","family":"string","arity":"required"},"default":"ADMIN","autoIncrement":false},{"name":"status","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["location"],"referencedTable":"Location","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateTable":{"table":{"name":"Post","columns":[{"name":"createdAt","tpe":{"raw":"","family":"dateTime","arity":"required"},"default":"1970-01-01 00:00:00","autoIncrement":false},{"name":"email","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"updatedAt","tpe":{"raw":"","family":"dateTime","arity":"required"},"default":"1970-01-01 00:00:00","autoIncrement":false},{"name":"user","tpe":{"raw":"","family":"string","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[{"name":"Post.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["user"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateTable":{"table":{"name":"Location","columns":[{"name":"city","tpe":{"raw":"","family":"string","arity":"required"},"default":"","autoIncrement":false},{"name":"id","tpe":{"raw":"","family":"int","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}}},{"CreateIndex":{"table":"User","index":{"name":"User.email","columns":["email"],"tpe":"unique"}}},{"CreateIndex":{"table":"Post","index":{"name":"Post.email","columns":["email"],"tpe":"unique"}}},{"AddForeignKey":{"table":"User","foreign_key":{"constraintName":null,"columns":["location"],"referencedTable":"Location","referencedColumns":["id"],"onDeleteAction":"setNull"}}},{"AddForeignKey":{"table":"Post","foreign_key":{"constraintName":null,"columns":["user"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}}}],"rollback":[{"DropIndex":{"table":"User","name":"User.email"}},{"DropIndex":{"table":"Post","name":"Post.email"}},{"DropTable":{"name":"User"}},{"DropTable":{"name":"Post"}},{"DropTable":{"name":"Location"}}]}


