{-|
Module: IHP.IDE.SchemaDesigner.Types
Description: Types for representing an AST of SQL DDL
Copyright: (c) digitally induced GmbH, 2020
-}
module IHP.IDE.SchemaDesigner.Types where

import IHP.Prelude

data Statement
    =
    -- | CREATE TABLE name ( columns );
      StatementCreateTable { Statement -> CreateTable
unsafeGetCreateTable :: CreateTable }
    -- | CREATE TYPE name AS ENUM ( values );
    | CreateEnumType { Statement -> Text
name :: Text, Statement -> [Text]
values :: [Text] }
    -- | DROP TYPE name;
    | DropEnumType { name :: Text }
    -- | CREATE EXTENSION IF NOT EXISTS "name";
    | CreateExtension { name :: Text, Statement -> Bool
ifNotExists :: Bool }
    -- | ALTER TABLE tableName ADD CONSTRAINT constraint;
    | AddConstraint { Statement -> Text
tableName :: Text, Statement -> Constraint
constraint :: Constraint, Statement -> Maybe Bool
deferrable :: Maybe Bool, Statement -> Maybe DeferrableType
deferrableType :: Maybe DeferrableType }
    -- | ALTER TABLE tableName DROP CONSTRAINT constraintName;
    | DropConstraint { tableName, Statement -> Text
constraintName :: Text }
    -- | ALTER TABLE tableName ADD COLUMN column;
    | AddColumn { tableName :: Text, Statement -> Column
column :: Column }
    -- | ALTER TABLE tableName DROP COLUMN columnName;
    | DropColumn { tableName :: Text, Statement -> Text
columnName :: Text }
    -- | DROP TABLE tableName;
    | DropTable { tableName :: Text }
    | UnknownStatement { Statement -> Text
raw :: Text }
    | Comment { Statement -> Text
content :: Text }
    -- | CREATE INDEX indexName ON tableName (columnName); CREATE INDEX indexName ON tableName (LOWER(columnName));
    -- | CREATE UNIQUE INDEX name ON table (column [, ...]);
    | CreateIndex { Statement -> Text
indexName :: Text, Statement -> Bool
unique :: Bool, tableName :: Text, Statement -> [IndexColumn]
columns :: [IndexColumn], Statement -> Maybe Expression
whereClause :: Maybe Expression, Statement -> Maybe IndexType
indexType :: Maybe IndexType }
    -- | DROP INDEX indexName;
    | DropIndex { indexName :: Text }
    -- | CREATE OR REPLACE FUNCTION functionName(param1 TEXT, param2 INT) RETURNS TRIGGER AS $$functionBody$$ language plpgsql;
    | CreateFunction { Statement -> Text
functionName :: Text, Statement -> [(Text, PostgresType)]
functionArguments :: [(Text, PostgresType)], Statement -> Text
functionBody :: Text, Statement -> Bool
orReplace :: Bool, Statement -> PostgresType
returns :: PostgresType, Statement -> Text
language :: Text }
    -- | ALTER TABLE tableName ENABLE ROW LEVEL SECURITY;
    | EnableRowLevelSecurity { tableName :: Text }
    -- CREATE POLICY name ON tableName USING using WITH CHECK check;
    | CreatePolicy { name :: Text, tableName :: Text, Statement -> Maybe PolicyAction
action :: Maybe PolicyAction, Statement -> Maybe Expression
using :: Maybe Expression, Statement -> Maybe Expression
check :: Maybe Expression }
    -- SET name = value;
    | Set { name :: Text, Statement -> Expression
value :: Expression }
    -- SELECT query;
    | SelectStatement { Statement -> Text
query :: Text }
    -- CREATE SEQUENCE name;
    | CreateSequence { name :: Text }
    -- ALTER TABLE tableName RENAME COLUMN from TO to;
    | RenameColumn { tableName :: Text, Statement -> Text
from :: Text, Statement -> Text
to :: Text }
    -- ALTER TYPE enumName ADD VALUE newValue;
    | AddValueToEnumType { Statement -> Text
enumName :: Text, Statement -> Text
newValue :: Text, ifNotExists :: Bool }
    -- ALTER TABLE tableName ALTER COLUMN columnName DROP NOT NULL;
    | DropNotNull { tableName :: Text, columnName :: Text }
    -- ALTER TABLE tableName ALTER COLUMN columnName SET NOT NULL;
    | SetNotNull { tableName :: Text, columnName :: Text }
    -- | ALTER TABLE from RENAME TO to;
    | RenameTable { from :: Text, to :: Text }
    -- | DROP POLICY policyName ON tableName;
    | DropPolicy { tableName :: Text, Statement -> Text
policyName :: Text }
    -- ALTER TABLE tableName ALTER COLUMN columnName SET DEFAULT 'value';
    | SetDefaultValue { tableName :: Text, columnName :: Text, value :: Expression }
    -- ALTER TABLE tableName ALTER COLUMN columnName DROP DEFAULT;
    | DropDefaultValue { tableName :: Text, columnName :: Text }
    -- | CREATE TRIGGER ..;
    | CreateTrigger { name :: !Text, Statement -> TriggerEventWhen
eventWhen :: !TriggerEventWhen, Statement -> TriggerEvent
event :: !TriggerEvent, tableName :: !Text, Statement -> TriggerFor
for :: !TriggerFor, Statement -> Maybe Expression
whenCondition :: Maybe Expression, functionName :: !Text, Statement -> [Expression]
arguments :: ![Expression] }
    -- | BEGIN;
    | Begin
    -- | COMMIT;
    | Commit
    | DropFunction { functionName :: !Text }
    deriving (Statement -> Statement -> Bool
(Statement -> Statement -> Bool)
-> (Statement -> Statement -> Bool) -> Eq Statement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Statement -> Statement -> Bool
$c/= :: Statement -> Statement -> Bool
== :: Statement -> Statement -> Bool
$c== :: Statement -> Statement -> Bool
Eq, Int -> Statement -> ShowS
[Statement] -> ShowS
Statement -> String
(Int -> Statement -> ShowS)
-> (Statement -> String)
-> ([Statement] -> ShowS)
-> Show Statement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Statement] -> ShowS
$cshowList :: [Statement] -> ShowS
show :: Statement -> String
$cshow :: Statement -> String
showsPrec :: Int -> Statement -> ShowS
$cshowsPrec :: Int -> Statement -> ShowS
Show)

data DeferrableType
    = InitiallyImmediate
    | InitiallyDeferred
    deriving (DeferrableType -> DeferrableType -> Bool
(DeferrableType -> DeferrableType -> Bool)
-> (DeferrableType -> DeferrableType -> Bool) -> Eq DeferrableType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeferrableType -> DeferrableType -> Bool
$c/= :: DeferrableType -> DeferrableType -> Bool
== :: DeferrableType -> DeferrableType -> Bool
$c== :: DeferrableType -> DeferrableType -> Bool
Eq, Int -> DeferrableType -> ShowS
[DeferrableType] -> ShowS
DeferrableType -> String
(Int -> DeferrableType -> ShowS)
-> (DeferrableType -> String)
-> ([DeferrableType] -> ShowS)
-> Show DeferrableType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeferrableType] -> ShowS
$cshowList :: [DeferrableType] -> ShowS
show :: DeferrableType -> String
$cshow :: DeferrableType -> String
showsPrec :: Int -> DeferrableType -> ShowS
$cshowsPrec :: Int -> DeferrableType -> ShowS
Show)

data CreateTable
  = CreateTable
      { CreateTable -> Text
name :: Text
      , CreateTable -> [Column]
columns :: [Column]
      , CreateTable -> PrimaryKeyConstraint
primaryKeyConstraint :: PrimaryKeyConstraint
      , CreateTable -> [Constraint]
constraints :: [Constraint]
      }
  deriving (CreateTable -> CreateTable -> Bool
(CreateTable -> CreateTable -> Bool)
-> (CreateTable -> CreateTable -> Bool) -> Eq CreateTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTable -> CreateTable -> Bool
$c/= :: CreateTable -> CreateTable -> Bool
== :: CreateTable -> CreateTable -> Bool
$c== :: CreateTable -> CreateTable -> Bool
Eq, Int -> CreateTable -> ShowS
[CreateTable] -> ShowS
CreateTable -> String
(Int -> CreateTable -> ShowS)
-> (CreateTable -> String)
-> ([CreateTable] -> ShowS)
-> Show CreateTable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTable] -> ShowS
$cshowList :: [CreateTable] -> ShowS
show :: CreateTable -> String
$cshow :: CreateTable -> String
showsPrec :: Int -> CreateTable -> ShowS
$cshowsPrec :: Int -> CreateTable -> ShowS
Show)

data Column = Column
    { Column -> Text
name :: Text
    , Column -> PostgresType
columnType :: PostgresType
    , Column -> Maybe Expression
defaultValue :: Maybe Expression
    , Column -> Bool
notNull :: Bool
    , Column -> Bool
isUnique :: Bool
    , Column -> Maybe ColumnGenerator
generator :: Maybe ColumnGenerator
    }
    deriving (Column -> Column -> Bool
(Column -> Column -> Bool)
-> (Column -> Column -> Bool) -> Eq Column
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Column -> Column -> Bool
$c/= :: Column -> Column -> Bool
== :: Column -> Column -> Bool
$c== :: Column -> Column -> Bool
Eq, Int -> Column -> ShowS
[Column] -> ShowS
Column -> String
(Int -> Column -> ShowS)
-> (Column -> String) -> ([Column] -> ShowS) -> Show Column
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Column] -> ShowS
$cshowList :: [Column] -> ShowS
show :: Column -> String
$cshow :: Column -> String
showsPrec :: Int -> Column -> ShowS
$cshowsPrec :: Int -> Column -> ShowS
Show)

data OnDelete
    = NoAction
    | Restrict
    | SetNull
    | SetDefault
    | Cascade
    deriving (Int -> OnDelete -> ShowS
[OnDelete] -> ShowS
OnDelete -> String
(Int -> OnDelete -> ShowS)
-> (OnDelete -> String) -> ([OnDelete] -> ShowS) -> Show OnDelete
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnDelete] -> ShowS
$cshowList :: [OnDelete] -> ShowS
show :: OnDelete -> String
$cshow :: OnDelete -> String
showsPrec :: Int -> OnDelete -> ShowS
$cshowsPrec :: Int -> OnDelete -> ShowS
Show, OnDelete -> OnDelete -> Bool
(OnDelete -> OnDelete -> Bool)
-> (OnDelete -> OnDelete -> Bool) -> Eq OnDelete
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnDelete -> OnDelete -> Bool
$c/= :: OnDelete -> OnDelete -> Bool
== :: OnDelete -> OnDelete -> Bool
$c== :: OnDelete -> OnDelete -> Bool
Eq)

data ColumnGenerator
    = ColumnGenerator
    { ColumnGenerator -> Expression
generate :: !Expression
    , ColumnGenerator -> Bool
stored :: !Bool
    } deriving (Int -> ColumnGenerator -> ShowS
[ColumnGenerator] -> ShowS
ColumnGenerator -> String
(Int -> ColumnGenerator -> ShowS)
-> (ColumnGenerator -> String)
-> ([ColumnGenerator] -> ShowS)
-> Show ColumnGenerator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnGenerator] -> ShowS
$cshowList :: [ColumnGenerator] -> ShowS
show :: ColumnGenerator -> String
$cshow :: ColumnGenerator -> String
showsPrec :: Int -> ColumnGenerator -> ShowS
$cshowsPrec :: Int -> ColumnGenerator -> ShowS
Show, ColumnGenerator -> ColumnGenerator -> Bool
(ColumnGenerator -> ColumnGenerator -> Bool)
-> (ColumnGenerator -> ColumnGenerator -> Bool)
-> Eq ColumnGenerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnGenerator -> ColumnGenerator -> Bool
$c/= :: ColumnGenerator -> ColumnGenerator -> Bool
== :: ColumnGenerator -> ColumnGenerator -> Bool
$c== :: ColumnGenerator -> ColumnGenerator -> Bool
Eq)

newtype PrimaryKeyConstraint
  = PrimaryKeyConstraint { PrimaryKeyConstraint -> [Text]
primaryKeyColumnNames :: [Text] }
  deriving (PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
(PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool)
-> (PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool)
-> Eq PrimaryKeyConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
$c/= :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
== :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
$c== :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
Eq, Int -> PrimaryKeyConstraint -> ShowS
[PrimaryKeyConstraint] -> ShowS
PrimaryKeyConstraint -> String
(Int -> PrimaryKeyConstraint -> ShowS)
-> (PrimaryKeyConstraint -> String)
-> ([PrimaryKeyConstraint] -> ShowS)
-> Show PrimaryKeyConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrimaryKeyConstraint] -> ShowS
$cshowList :: [PrimaryKeyConstraint] -> ShowS
show :: PrimaryKeyConstraint -> String
$cshow :: PrimaryKeyConstraint -> String
showsPrec :: Int -> PrimaryKeyConstraint -> ShowS
$cshowsPrec :: Int -> PrimaryKeyConstraint -> ShowS
Show)

data Constraint
    -- | FOREIGN KEY (columnName) REFERENCES referenceTable (referenceColumn) ON DELETE onDelete;
    = ForeignKeyConstraint
        { Constraint -> Maybe Text
name :: !(Maybe Text)
        , Constraint -> Text
columnName :: !Text
        , Constraint -> Text
referenceTable :: !Text
        , Constraint -> Maybe Text
referenceColumn :: !(Maybe Text)
        , Constraint -> Maybe OnDelete
onDelete :: !(Maybe OnDelete)
        }
    | UniqueConstraint
        { name :: !(Maybe Text)
        , Constraint -> [Text]
columnNames :: ![Text]
        }
    | CheckConstraint
        { name :: !(Maybe Text)
        , Constraint -> Expression
checkExpression :: !Expression
        }
    | ExcludeConstraint
        { name :: !(Maybe Text)
        , Constraint -> [ExcludeConstraintElement]
excludeElements :: ![ExcludeConstraintElement]
        , Constraint -> Maybe Expression
predicate :: !(Maybe Expression)
        , Constraint -> Maybe IndexType
indexType :: !(Maybe IndexType)
        }
    | AlterTableAddPrimaryKey
        { name :: !(Maybe Text)
        , Constraint -> PrimaryKeyConstraint
primaryKeyConstraint :: !PrimaryKeyConstraint
        }
    deriving (Constraint -> Constraint -> Bool
(Constraint -> Constraint -> Bool)
-> (Constraint -> Constraint -> Bool) -> Eq Constraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Constraint -> Constraint -> Bool
$c/= :: Constraint -> Constraint -> Bool
== :: Constraint -> Constraint -> Bool
$c== :: Constraint -> Constraint -> Bool
Eq, Int -> Constraint -> ShowS
[Constraint] -> ShowS
Constraint -> String
(Int -> Constraint -> ShowS)
-> (Constraint -> String)
-> ([Constraint] -> ShowS)
-> Show Constraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Constraint] -> ShowS
$cshowList :: [Constraint] -> ShowS
show :: Constraint -> String
$cshow :: Constraint -> String
showsPrec :: Int -> Constraint -> ShowS
$cshowsPrec :: Int -> Constraint -> ShowS
Show)

data ExcludeConstraintElement = ExcludeConstraintElement { ExcludeConstraintElement -> Text
element :: !Text, ExcludeConstraintElement -> Text
operator :: !Text }
    deriving (ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
(ExcludeConstraintElement -> ExcludeConstraintElement -> Bool)
-> (ExcludeConstraintElement -> ExcludeConstraintElement -> Bool)
-> Eq ExcludeConstraintElement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
$c/= :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
== :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
$c== :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
Eq, Int -> ExcludeConstraintElement -> ShowS
[ExcludeConstraintElement] -> ShowS
ExcludeConstraintElement -> String
(Int -> ExcludeConstraintElement -> ShowS)
-> (ExcludeConstraintElement -> String)
-> ([ExcludeConstraintElement] -> ShowS)
-> Show ExcludeConstraintElement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExcludeConstraintElement] -> ShowS
$cshowList :: [ExcludeConstraintElement] -> ShowS
show :: ExcludeConstraintElement -> String
$cshow :: ExcludeConstraintElement -> String
showsPrec :: Int -> ExcludeConstraintElement -> ShowS
$cshowsPrec :: Int -> ExcludeConstraintElement -> ShowS
Show)

data Expression =
    -- | Sql string like @'hello'@
    TextExpression Text
    -- | Simple variable like @users@
    | VarExpression Text
    -- | Simple call, like @COALESCE(name, 'unknown name')@
    | CallExpression Text [Expression]
    -- | Not equal operator, a <> b
    | NotEqExpression Expression Expression
    -- | Equal operator, a = b
    | EqExpression Expression Expression
    -- | a AND b
    | AndExpression Expression Expression
    -- | a IS b
    | IsExpression Expression Expression
    -- | NOT a
    | NotExpression Expression
    -- | EXISTS a
    | ExistsExpression Expression
    -- | a OR b
    | OrExpression Expression Expression
    -- | a < b
    | LessThanExpression Expression Expression
    -- | a <= b
    | LessThanOrEqualToExpression Expression Expression
    -- | a > b
    | GreaterThanExpression Expression Expression
    -- | a >= b
    | GreaterThanOrEqualToExpression Expression Expression
    -- | Double literal value, e.g. 0.1337
    | DoubleExpression Double
    -- | Integer literal value, e.g. 1337
    | IntExpression Int
    -- | value::type
    | TypeCastExpression Expression PostgresType
    | SelectExpression Select
    | DotExpression Expression Text
    | ConcatenationExpression Expression Expression -- ^ a || b
    deriving (Expression -> Expression -> Bool
(Expression -> Expression -> Bool)
-> (Expression -> Expression -> Bool) -> Eq Expression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Expression -> Expression -> Bool
$c/= :: Expression -> Expression -> Bool
== :: Expression -> Expression -> Bool
$c== :: Expression -> Expression -> Bool
Eq, Int -> Expression -> ShowS
[Expression] -> ShowS
Expression -> String
(Int -> Expression -> ShowS)
-> (Expression -> String)
-> ([Expression] -> ShowS)
-> Show Expression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Expression] -> ShowS
$cshowList :: [Expression] -> ShowS
show :: Expression -> String
$cshow :: Expression -> String
showsPrec :: Int -> Expression -> ShowS
$cshowsPrec :: Int -> Expression -> ShowS
Show)

data Select = Select
    { Select -> [Expression]
columns :: [Expression]
    , Select -> Expression
from :: Expression
    , Select -> Maybe Text
alias :: Maybe Text
    , Select -> Expression
whereClause :: Expression
    } deriving (Select -> Select -> Bool
(Select -> Select -> Bool)
-> (Select -> Select -> Bool) -> Eq Select
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Select -> Select -> Bool
$c/= :: Select -> Select -> Bool
== :: Select -> Select -> Bool
$c== :: Select -> Select -> Bool
Eq, Int -> Select -> ShowS
[Select] -> ShowS
Select -> String
(Int -> Select -> ShowS)
-> (Select -> String) -> ([Select] -> ShowS) -> Show Select
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Select] -> ShowS
$cshowList :: [Select] -> ShowS
show :: Select -> String
$cshow :: Select -> String
showsPrec :: Int -> Select -> ShowS
$cshowsPrec :: Int -> Select -> ShowS
Show)

data PostgresType
    = PUUID
    | PText
    | PInt
    | PSmallInt
    | PBigInt
    | PBoolean
    | PTimestampWithTimezone
    | PTimestamp
    | PReal
    | PDouble
    | PPoint
    | PPolygon
    | PDate
    | PBinary
    | PTime
    | PNumeric { PostgresType -> Maybe Int
precision :: Maybe Int, PostgresType -> Maybe Int
scale :: Maybe Int }
    | PVaryingN (Maybe Int)
    | PCharacterN Int
    | PSingleChar
    | PSerial
    | PBigserial
    | PJSONB
    | PInet
    | PTSVector
    | PArray PostgresType
    | PTrigger
    | PCustomType Text
    deriving (PostgresType -> PostgresType -> Bool
(PostgresType -> PostgresType -> Bool)
-> (PostgresType -> PostgresType -> Bool) -> Eq PostgresType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostgresType -> PostgresType -> Bool
$c/= :: PostgresType -> PostgresType -> Bool
== :: PostgresType -> PostgresType -> Bool
$c== :: PostgresType -> PostgresType -> Bool
Eq, Int -> PostgresType -> ShowS
[PostgresType] -> ShowS
PostgresType -> String
(Int -> PostgresType -> ShowS)
-> (PostgresType -> String)
-> ([PostgresType] -> ShowS)
-> Show PostgresType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostgresType] -> ShowS
$cshowList :: [PostgresType] -> ShowS
show :: PostgresType -> String
$cshow :: PostgresType -> String
showsPrec :: Int -> PostgresType -> ShowS
$cshowsPrec :: Int -> PostgresType -> ShowS
Show)

data TriggerEventWhen
    = Before
    | After
    | InsteadOf
    deriving (TriggerEventWhen -> TriggerEventWhen -> Bool
(TriggerEventWhen -> TriggerEventWhen -> Bool)
-> (TriggerEventWhen -> TriggerEventWhen -> Bool)
-> Eq TriggerEventWhen
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TriggerEventWhen -> TriggerEventWhen -> Bool
$c/= :: TriggerEventWhen -> TriggerEventWhen -> Bool
== :: TriggerEventWhen -> TriggerEventWhen -> Bool
$c== :: TriggerEventWhen -> TriggerEventWhen -> Bool
Eq, Int -> TriggerEventWhen -> ShowS
[TriggerEventWhen] -> ShowS
TriggerEventWhen -> String
(Int -> TriggerEventWhen -> ShowS)
-> (TriggerEventWhen -> String)
-> ([TriggerEventWhen] -> ShowS)
-> Show TriggerEventWhen
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TriggerEventWhen] -> ShowS
$cshowList :: [TriggerEventWhen] -> ShowS
show :: TriggerEventWhen -> String
$cshow :: TriggerEventWhen -> String
showsPrec :: Int -> TriggerEventWhen -> ShowS
$cshowsPrec :: Int -> TriggerEventWhen -> ShowS
Show)

data TriggerEvent
    = TriggerOnInsert
    | TriggerOnUpdate
    | TriggerOnDelete
    | TriggerOnTruncate
    deriving (TriggerEvent -> TriggerEvent -> Bool
(TriggerEvent -> TriggerEvent -> Bool)
-> (TriggerEvent -> TriggerEvent -> Bool) -> Eq TriggerEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TriggerEvent -> TriggerEvent -> Bool
$c/= :: TriggerEvent -> TriggerEvent -> Bool
== :: TriggerEvent -> TriggerEvent -> Bool
$c== :: TriggerEvent -> TriggerEvent -> Bool
Eq, Int -> TriggerEvent -> ShowS
[TriggerEvent] -> ShowS
TriggerEvent -> String
(Int -> TriggerEvent -> ShowS)
-> (TriggerEvent -> String)
-> ([TriggerEvent] -> ShowS)
-> Show TriggerEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TriggerEvent] -> ShowS
$cshowList :: [TriggerEvent] -> ShowS
show :: TriggerEvent -> String
$cshow :: TriggerEvent -> String
showsPrec :: Int -> TriggerEvent -> ShowS
$cshowsPrec :: Int -> TriggerEvent -> ShowS
Show)

data TriggerFor
    = ForEachRow
    | ForEachStatement
    deriving (TriggerFor -> TriggerFor -> Bool
(TriggerFor -> TriggerFor -> Bool)
-> (TriggerFor -> TriggerFor -> Bool) -> Eq TriggerFor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TriggerFor -> TriggerFor -> Bool
$c/= :: TriggerFor -> TriggerFor -> Bool
== :: TriggerFor -> TriggerFor -> Bool
$c== :: TriggerFor -> TriggerFor -> Bool
Eq, Int -> TriggerFor -> ShowS
[TriggerFor] -> ShowS
TriggerFor -> String
(Int -> TriggerFor -> ShowS)
-> (TriggerFor -> String)
-> ([TriggerFor] -> ShowS)
-> Show TriggerFor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TriggerFor] -> ShowS
$cshowList :: [TriggerFor] -> ShowS
show :: TriggerFor -> String
$cshow :: TriggerFor -> String
showsPrec :: Int -> TriggerFor -> ShowS
$cshowsPrec :: Int -> TriggerFor -> ShowS
Show)

data PolicyAction
    = PolicyForAll
    | PolicyForSelect
    | PolicyForInsert
    | PolicyForUpdate
    | PolicyForDelete
    deriving (PolicyAction -> PolicyAction -> Bool
(PolicyAction -> PolicyAction -> Bool)
-> (PolicyAction -> PolicyAction -> Bool) -> Eq PolicyAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyAction -> PolicyAction -> Bool
$c/= :: PolicyAction -> PolicyAction -> Bool
== :: PolicyAction -> PolicyAction -> Bool
$c== :: PolicyAction -> PolicyAction -> Bool
Eq, Int -> PolicyAction -> ShowS
[PolicyAction] -> ShowS
PolicyAction -> String
(Int -> PolicyAction -> ShowS)
-> (PolicyAction -> String)
-> ([PolicyAction] -> ShowS)
-> Show PolicyAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyAction] -> ShowS
$cshowList :: [PolicyAction] -> ShowS
show :: PolicyAction -> String
$cshow :: PolicyAction -> String
showsPrec :: Int -> PolicyAction -> ShowS
$cshowsPrec :: Int -> PolicyAction -> ShowS
Show)

data IndexType = Btree | Gin | Gist
    deriving (IndexType -> IndexType -> Bool
(IndexType -> IndexType -> Bool)
-> (IndexType -> IndexType -> Bool) -> Eq IndexType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IndexType -> IndexType -> Bool
$c/= :: IndexType -> IndexType -> Bool
== :: IndexType -> IndexType -> Bool
$c== :: IndexType -> IndexType -> Bool
Eq, Int -> IndexType -> ShowS
[IndexType] -> ShowS
IndexType -> String
(Int -> IndexType -> ShowS)
-> (IndexType -> String)
-> ([IndexType] -> ShowS)
-> Show IndexType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IndexType] -> ShowS
$cshowList :: [IndexType] -> ShowS
show :: IndexType -> String
$cshow :: IndexType -> String
showsPrec :: Int -> IndexType -> ShowS
$cshowsPrec :: Int -> IndexType -> ShowS
Show)

data IndexColumn
    = IndexColumn { IndexColumn -> Expression
column :: Expression, IndexColumn -> [IndexColumnOrder]
columnOrder :: [IndexColumnOrder] }
    deriving (IndexColumn -> IndexColumn -> Bool
(IndexColumn -> IndexColumn -> Bool)
-> (IndexColumn -> IndexColumn -> Bool) -> Eq IndexColumn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IndexColumn -> IndexColumn -> Bool
$c/= :: IndexColumn -> IndexColumn -> Bool
== :: IndexColumn -> IndexColumn -> Bool
$c== :: IndexColumn -> IndexColumn -> Bool
Eq, Int -> IndexColumn -> ShowS
[IndexColumn] -> ShowS
IndexColumn -> String
(Int -> IndexColumn -> ShowS)
-> (IndexColumn -> String)
-> ([IndexColumn] -> ShowS)
-> Show IndexColumn
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IndexColumn] -> ShowS
$cshowList :: [IndexColumn] -> ShowS
show :: IndexColumn -> String
$cshow :: IndexColumn -> String
showsPrec :: Int -> IndexColumn -> ShowS
$cshowsPrec :: Int -> IndexColumn -> ShowS
Show)

data IndexColumnOrder
    = Asc | Desc | NullsFirst | NullsLast
    deriving (IndexColumnOrder -> IndexColumnOrder -> Bool
(IndexColumnOrder -> IndexColumnOrder -> Bool)
-> (IndexColumnOrder -> IndexColumnOrder -> Bool)
-> Eq IndexColumnOrder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IndexColumnOrder -> IndexColumnOrder -> Bool
$c/= :: IndexColumnOrder -> IndexColumnOrder -> Bool
== :: IndexColumnOrder -> IndexColumnOrder -> Bool
$c== :: IndexColumnOrder -> IndexColumnOrder -> Bool
Eq, Int -> IndexColumnOrder -> ShowS
[IndexColumnOrder] -> ShowS
IndexColumnOrder -> String
(Int -> IndexColumnOrder -> ShowS)
-> (IndexColumnOrder -> String)
-> ([IndexColumnOrder] -> ShowS)
-> Show IndexColumnOrder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IndexColumnOrder] -> ShowS
$cshowList :: [IndexColumnOrder] -> ShowS
show :: IndexColumnOrder -> String
$cshow :: IndexColumnOrder -> String
showsPrec :: Int -> IndexColumnOrder -> ShowS
$cshowsPrec :: Int -> IndexColumnOrder -> ShowS
Show)