# _Migration

name: 20201003131039-initial-structure
status: MigrationSuccess
errors: []
datamodel:
  datasource db {
    provider = "sqlite"
    url      = "***"
  }

  model User {
    id        Int      @id @default(autoincrement())
    name      String
    email     String?
    createdAt DateTime @default(now())
    polls     Poll[]
  }

  model Poll {
    id          Int        @id @default(autoincrement())
    User        User?      @relation(fields: [userId], references: [id])
    userId      Int?
    title       String
    description String?
    slug        String     @unique
    questions   Question[]
    createdAt   DateTime   @default(now())
  }

  model Question {
    id       Int       @id @default(autoincrement())
    Poll     Poll?     @relation(fields: [pollId], references: [id])
    pollId   Int?
    title    String
    variants Variant[]
  }

  model Variant {
    id         Int       @id @default(autoincrement())
    Question   Question? @relation(fields: [questionId], references: [id])
    questionId Int?
    text       String
    count      Int       @default(0)
  }

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":"\"***\""},{"tag":"CreateModel","model":"User"},{"tag":"CreateField","model":"User","field":"id","type":"Int","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":"autoincrement()"},{"tag":"CreateField","model":"User","field":"name","type":"String","arity":"Required"},{"tag":"CreateField","model":"User","field":"email","type":"String","arity":"Optional"},{"tag":"CreateField","model":"User","field":"createdAt","type":"DateTime","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"User","field":"createdAt"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"User","field":"createdAt"},"directive":"default"},"argument":"","value":"now()"},{"tag":"CreateField","model":"User","field":"polls","type":"Poll","arity":"List"},{"tag":"CreateModel","model":"Poll"},{"tag":"CreateField","model":"Poll","field":"id","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Poll","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Poll","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Poll","field":"id"},"directive":"default"},"argument":"","value":"autoincrement()"},{"tag":"CreateField","model":"Poll","field":"User","type":"User","arity":"Optional"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Poll","field":"User"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Poll","field":"User"},"directive":"relation"},"argument":"fields","value":"[userId]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Poll","field":"User"},"directive":"relation"},"argument":"references","value":"[id]"},{"tag":"CreateField","model":"Poll","field":"userId","type":"Int","arity":"Optional"},{"tag":"CreateField","model":"Poll","field":"title","type":"String","arity":"Required"},{"tag":"CreateField","model":"Poll","field":"description","type":"String","arity":"Optional"},{"tag":"CreateField","model":"Poll","field":"slug","type":"String","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Poll","field":"slug"},"directive":"unique"}},{"tag":"CreateField","model":"Poll","field":"questions","type":"Question","arity":"List"},{"tag":"CreateField","model":"Poll","field":"createdAt","type":"DateTime","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Poll","field":"createdAt"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Poll","field":"createdAt"},"directive":"default"},"argument":"","value":"now()"},{"tag":"CreateModel","model":"Question"},{"tag":"CreateField","model":"Question","field":"id","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Question","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Question","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Question","field":"id"},"directive":"default"},"argument":"","value":"autoincrement()"},{"tag":"CreateField","model":"Question","field":"Poll","type":"Poll","arity":"Optional"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Question","field":"Poll"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Question","field":"Poll"},"directive":"relation"},"argument":"fields","value":"[pollId]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Question","field":"Poll"},"directive":"relation"},"argument":"references","value":"[id]"},{"tag":"CreateField","model":"Question","field":"pollId","type":"Int","arity":"Optional"},{"tag":"CreateField","model":"Question","field":"title","type":"String","arity":"Required"},{"tag":"CreateField","model":"Question","field":"variants","type":"Variant","arity":"List"},{"tag":"CreateModel","model":"Variant"},{"tag":"CreateField","model":"Variant","field":"id","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Variant","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Variant","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Variant","field":"id"},"directive":"default"},"argument":"","value":"autoincrement()"},{"tag":"CreateField","model":"Variant","field":"Question","type":"Question","arity":"Optional"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Variant","field":"Question"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Variant","field":"Question"},"directive":"relation"},"argument":"fields","value":"[questionId]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Variant","field":"Question"},"directive":"relation"},"argument":"references","value":"[id]"},{"tag":"CreateField","model":"Variant","field":"questionId","type":"Int","arity":"Optional"},{"tag":"CreateField","model":"Variant","field":"text","type":"String","arity":"Required"},{"tag":"CreateField","model":"Variant","field":"count","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Variant","field":"count"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Variant","field":"count"},"directive":"default"},"argument":"","value":"0"}]

database_migration:
  {"before":{"tables":[{"name":"_Migration","columns":[{"name":"revision","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required"},"default":null,"autoIncrement":true},{"name":"name","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":"status","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"applied","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required"},"default":null,"autoIncrement":false},{"name":"rolled_back","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","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":"database_migration","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":"started_at","tpe":{"dataType":"DATE","fullDataType":"DATE","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":null,"autoIncrement":false},{"name":"finished_at","tpe":{"dataType":"DATE","fullDataType":"DATE","characterMaximumLength":null,"family":"dateTime","arity":"nullable"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["revision"],"sequence":null,"constraintName":null},"foreignKeys":[]}],"enums":[],"sequences":[]},"after":{"tables":[{"name":"User","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"name","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"email","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}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[]},{"name":"Poll","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"userId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"description","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"slug","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"createdAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":"NOW","autoIncrement":false}],"indices":[{"name":"Poll.slug_unique","columns":["slug"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["userId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]},{"name":"Question","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"pollId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["pollId"],"referencedTable":"Poll","referencedColumns":["id"],"onDeleteAction":"setNull"}]},{"name":"Variant","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"questionId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"text","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"count","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"VALUE":0},"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["questionId"],"referencedTable":"Question","referencedColumns":["id"],"onDeleteAction":"setNull"}]}],"enums":[],"sequences":[]},"steps":[{"CreateTable":{"table":{"name":"User","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"name","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"email","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}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[]}}},{"CreateTable":{"table":{"name":"Poll","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"userId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"description","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"slug","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"createdAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required"},"default":"NOW","autoIncrement":false}],"indices":[{"name":"Poll.slug_unique","columns":["slug"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["userId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateTable":{"table":{"name":"Question","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"pollId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"title","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["pollId"],"referencedTable":"Poll","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateTable":{"table":{"name":"Variant","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"questionId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"nullable"},"default":null,"autoIncrement":false},{"name":"text","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required"},"default":null,"autoIncrement":false},{"name":"count","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required"},"default":{"VALUE":0},"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["questionId"],"referencedTable":"Question","referencedColumns":["id"],"onDeleteAction":"setNull"}]}}},{"CreateIndex":{"table":"Poll","index":{"name":"Poll.slug_unique","columns":["slug"],"tpe":"unique"},"caused_by_create_table":true}}]}


