# _Migration

name: watch-20200702111346
status: MigrationSuccess
errors: []
datamodel:
datasource db {
  provider = "sqlite"
  url      = "file:dev.db"
  default  = true
}

model User {
  id    String  @default(uuid()) @id
  email String  @unique
  name  String?
  posts Post[]
}

model Post {
  id        String   @default(cuid()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  authorId  String?
  author    User?    @relation(fields: [authorId], references: [id])
}

datamodel_steps:
[{"tag":"CreateSource","source":"db"},{"tag":"CreateArgument","location":{"tag":"Source","source":"db"},"argument":"provider","value":"\"sqlite\""},{"tag":"CreateArgument","location":{"tag":"Source","source":"db"},"argument":"url","value":"\"file:dev.db\""},{"tag":"CreateArgument","location":{"tag":"Source","source":"db"},"argument":"default","value":"true"},{"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":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"User","field":"id"},"directive":"default"},"argument":"","value":"uuid()"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"User","field":"id"},"directive":"id"}},{"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":"name","type":"String","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":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Post","field":"id"},"directive":"default"},"argument":"","value":"cuid()"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"id"},"directive":"id"}},{"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":"CreateField","model":"Post","field":"published","type":"Boolean","arity":"Required"},{"tag":"CreateField","model":"Post","field":"title","type":"String","arity":"Required"},{"tag":"CreateField","model":"Post","field":"content","type":"String","arity":"Optional"},{"tag":"CreateField","model":"Post","field":"authorId","type":"String","arity":"Optional"},{"tag":"CreateField","model":"Post","field":"author","type":"User","arity":"Optional"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Post","field":"author"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Post","field":"author"},"directive":"relation"},"argument":"fields","value":"[authorId]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Post","field":"author"},"directive":"relation"},"argument":"references","value":"[id]"}]

database_migration:
{"before":{"tables":[{"name":"_Migration","columns":[{"name":"applied","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required"},"default":null,"autoIncrement":false},{"name":"database_migration","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"datamodel","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"datamodel_steps","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"errors","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"finished_at","tpe":{"dataType":"DATE","fullDataType":"DATE","characterMaximumLength":null,"family":"dateTime","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"revision","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required"},"default":null,"autoIncrement":true},{"name":"rolled_back","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required"},"default":null,"autoIncrement":false},{"name":"started_at","tpe":{"dataType":"DATE","fullDataType":"DATE","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":null,"autoIncrement":false},{"name":"status","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"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":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]},{"name":"Post","columns":[{"name":"authorId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"content","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"createdAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":"NOW","autoIncrement":false},{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"published","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"boolean","arity":"required"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"updatedAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["authorId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]}],"enums":[],"sequences":[]},"original_steps":[{"CreateTable":{"table":{"name":"User","columns":[{"name":"email","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}}},{"CreateTable":{"table":{"name":"Post","columns":[{"name":"authorId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"content","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"createdAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":"NOW","autoIncrement":false},{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"published","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"boolean","arity":"required"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"updatedAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["authorId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateIndex":{"table":"User","index":{"name":"User.email","columns":["email"],"tpe":"unique"}}},{"AddForeignKey":{"table":"Post","foreign_key":{"constraintName":null,"columns":["authorId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}}}],"corrected_steps":[{"RawSql":{"raw":"PRAGMA foreign_keys=OFF;"}},{"CreateTable":{"table":{"name":"User","columns":[{"name":"email","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"name","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[{"name":"User.email","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[]}}},{"CreateTable":{"table":{"name":"Post","columns":[{"name":"authorId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"content","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"createdAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":"NOW","autoIncrement":false},{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"published","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"boolean","arity":"required"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"updatedAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null},"foreignKeys":[{"constraintName":null,"columns":["authorId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateIndex":{"table":"User","index":{"name":"User.email","columns":["email"],"tpe":"unique"}}},{"AddForeignKey":{"table":"Post","foreign_key":{"constraintName":null,"columns":["authorId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}}},{"RawSql":{"raw":"PRAGMA \"quaint\".foreign_key_check;"}},{"RawSql":{"raw":"PRAGMA foreign_keys=ON;"}}],"rollback":[{"RawSql":{"raw":"PRAGMA foreign_keys=OFF;"}},{"DropTable":{"name":"User"}},{"DropTable":{"name":"Post"}},{"RawSql":{"raw":"PRAGMA \"quaint\".foreign_key_check;"}},{"RawSql":{"raw":"PRAGMA foreign_keys=ON;"}}]}


