# _Migration

name: 20201125185150-init
status: MigrationSuccess
errors: []
datamodel:
  datasource db {
    provider = "sqlite"
    url      = "***"
  }

  model Link {
    id          Int      @id @default(autoincrement())
    createdAt   DateTime @default(now())
    description String
    url         String
    postedBy    User     @relation(fields: [postedById], references: [id])
    postedById  Int
    votes       Vote[]
  }

  model User {
    id       Int    @id @default(autoincrement())
    name     String
    email    String @unique
    password String
    links    Link[]
    votes    Vote[]
  }

  model Vote {
    id     Int  @id @default(autoincrement())
    link   Link @relation(fields: [linkId], references: [id])
    linkId Int
    user   User @relation(fields: [userId], references: [id])
    userId Int

    @@unique([linkId, userId])
  }

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":"Link"},{"tag":"CreateField","model":"Link","field":"id","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Link","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Link","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Link","field":"id"},"directive":"default"},"argument":"","value":"autoincrement()"},{"tag":"CreateField","model":"Link","field":"createdAt","type":"DateTime","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Link","field":"createdAt"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Link","field":"createdAt"},"directive":"default"},"argument":"","value":"now()"},{"tag":"CreateField","model":"Link","field":"description","type":"String","arity":"Required"},{"tag":"CreateField","model":"Link","field":"url","type":"String","arity":"Required"},{"tag":"CreateField","model":"Link","field":"postedBy","type":"User","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Link","field":"postedBy"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Link","field":"postedBy"},"directive":"relation"},"argument":"fields","value":"[postedById]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Link","field":"postedBy"},"directive":"relation"},"argument":"references","value":"[id]"},{"tag":"CreateField","model":"Link","field":"postedById","type":"Int","arity":"Required"},{"tag":"CreateField","model":"Link","field":"votes","type":"Vote","arity":"List"},{"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":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"User","field":"email"},"directive":"unique"}},{"tag":"CreateField","model":"User","field":"password","type":"String","arity":"Required"},{"tag":"CreateField","model":"User","field":"links","type":"Link","arity":"List"},{"tag":"CreateField","model":"User","field":"votes","type":"Vote","arity":"List"},{"tag":"CreateModel","model":"Vote"},{"tag":"CreateField","model":"Vote","field":"id","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Vote","field":"id"},"directive":"id"}},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Vote","field":"id"},"directive":"default"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Vote","field":"id"},"directive":"default"},"argument":"","value":"autoincrement()"},{"tag":"CreateField","model":"Vote","field":"link","type":"Link","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Vote","field":"link"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Vote","field":"link"},"directive":"relation"},"argument":"fields","value":"[linkId]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Vote","field":"link"},"directive":"relation"},"argument":"references","value":"[id]"},{"tag":"CreateField","model":"Vote","field":"linkId","type":"Int","arity":"Required"},{"tag":"CreateField","model":"Vote","field":"user","type":"User","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Field","model":"Vote","field":"user"},"directive":"relation"}},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Vote","field":"user"},"directive":"relation"},"argument":"fields","value":"[userId]"},{"tag":"CreateArgument","location":{"tag":"Directive","path":{"tag":"Field","model":"Vote","field":"user"},"directive":"relation"},"argument":"references","value":"[id]"},{"tag":"CreateField","model":"Vote","field":"userId","type":"Int","arity":"Required"},{"tag":"CreateDirective","location":{"path":{"tag":"Model","model":"Vote","arguments":[{"name":"","value":"[linkId, userId]"}]},"directive":"unique"}}]

database_migration:
  {"before":{"tables":[{"name":"_Migration","columns":[{"name":"revision","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":null,"autoIncrement":true},{"name":"name","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"datamodel","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"status","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"applied","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"rolled_back","tpe":{"dataType":"INTEGER","fullDataType":"INTEGER","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"datamodel_steps","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"database_migration","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"errors","tpe":{"dataType":"TEXT","fullDataType":"TEXT","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"started_at","tpe":{"dataType":"DATETIME","fullDataType":"DATETIME","characterMaximumLength":null,"family":"dateTime","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"finished_at","tpe":{"dataType":"DATETIME","fullDataType":"DATETIME","characterMaximumLength":null,"family":"dateTime","arity":"nullable","nativeType":null},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["revision"],"sequence":null,"constraintName":null},"foreignKeys":[]}],"enums":[],"sequences":[]},"after":{"tables":[{"name":"Link","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"createdAt","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"dateTime","arity":"required","nativeType":null},"default":"NOW","autoIncrement":false},{"name":"description","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"url","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"postedById","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":null,"autoIncrement":false}],"indices":[],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["postedById"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"cascade","onUpdateAction":"cascade"}]},{"name":"User","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"name","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"email","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"password","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"string","arity":"required","nativeType":null},"default":null,"autoIncrement":false}],"indices":[{"name":"User.email_unique","columns":["email"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[]},{"name":"Vote","columns":[{"name":"id","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":{"SEQUENCE":""},"autoIncrement":true},{"name":"linkId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":null,"autoIncrement":false},{"name":"userId","tpe":{"dataType":"","fullDataType":"","characterMaximumLength":null,"family":"int","arity":"required","nativeType":null},"default":null,"autoIncrement":false}],"indices":[{"name":"Vote.linkId_userId_unique","columns":["linkId","userId"],"tpe":"unique"}],"primaryKey":{"columns":["id"],"sequence":null,"constraintName":null},"foreignKeys":[{"constraintName":null,"columns":["linkId"],"referencedTable":"Link","referencedColumns":["id"],"onDeleteAction":"cascade","onUpdateAction":"cascade"},{"constraintName":null,"columns":["userId"],"referencedTable":"User","referencedColumns":["id"],"onDeleteAction":"cascade","onUpdateAction":"cascade"}]}],"enums":[],"sequences":[]},"steps":[{"CreateTable":{}},{"CreateTable":{}},{"CreateTable":{}},{"CreateIndex":{}},{"CreateIndex":{}}]}


