{-|
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] }
    -- | DROP TRIGGER .. ON ..;
    | DropTrigger { name :: !Text, tableName :: !Text }
    -- | 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
$c== :: Statement -> Statement -> Bool
== :: Statement -> Statement -> Bool
$c/= :: Statement -> Statement -> Bool
/= :: 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
$cshowsPrec :: Int -> Statement -> ShowS
showsPrec :: Int -> Statement -> ShowS
$cshow :: Statement -> String
show :: Statement -> String
$cshowList :: [Statement] -> ShowS
showList :: [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
$c== :: DeferrableType -> DeferrableType -> Bool
== :: DeferrableType -> DeferrableType -> Bool
$c/= :: DeferrableType -> DeferrableType -> Bool
/= :: 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
$cshowsPrec :: Int -> DeferrableType -> ShowS
showsPrec :: Int -> DeferrableType -> ShowS
$cshow :: DeferrableType -> String
show :: DeferrableType -> String
$cshowList :: [DeferrableType] -> ShowS
showList :: [DeferrableType] -> ShowS
Show)

data CreateTable
  = CreateTable
      { CreateTable -> Text
name :: Text
      , CreateTable -> [Column]
columns :: [Column]
      , CreateTable -> PrimaryKeyConstraint
primaryKeyConstraint :: PrimaryKeyConstraint
      , CreateTable -> [Constraint]
constraints :: [Constraint]
      , CreateTable -> Bool
unlogged :: !Bool
      }
  deriving (CreateTable -> CreateTable -> Bool
(CreateTable -> CreateTable -> Bool)
-> (CreateTable -> CreateTable -> Bool) -> Eq CreateTable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateTable -> CreateTable -> Bool
== :: CreateTable -> CreateTable -> Bool
$c/= :: CreateTable -> CreateTable -> Bool
/= :: 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
$cshowsPrec :: Int -> CreateTable -> ShowS
showsPrec :: Int -> CreateTable -> ShowS
$cshow :: CreateTable -> String
show :: CreateTable -> String
$cshowList :: [CreateTable] -> ShowS
showList :: [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
$c== :: Column -> Column -> Bool
== :: Column -> Column -> Bool
$c/= :: Column -> Column -> Bool
/= :: 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
$cshowsPrec :: Int -> Column -> ShowS
showsPrec :: Int -> Column -> ShowS
$cshow :: Column -> String
show :: Column -> String
$cshowList :: [Column] -> ShowS
showList :: [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
$cshowsPrec :: Int -> OnDelete -> ShowS
showsPrec :: Int -> OnDelete -> ShowS
$cshow :: OnDelete -> String
show :: OnDelete -> String
$cshowList :: [OnDelete] -> ShowS
showList :: [OnDelete] -> ShowS
Show, OnDelete -> OnDelete -> Bool
(OnDelete -> OnDelete -> Bool)
-> (OnDelete -> OnDelete -> Bool) -> Eq OnDelete
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OnDelete -> OnDelete -> Bool
== :: OnDelete -> OnDelete -> Bool
$c/= :: OnDelete -> OnDelete -> Bool
/= :: 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
$cshowsPrec :: Int -> ColumnGenerator -> ShowS
showsPrec :: Int -> ColumnGenerator -> ShowS
$cshow :: ColumnGenerator -> String
show :: ColumnGenerator -> String
$cshowList :: [ColumnGenerator] -> ShowS
showList :: [ColumnGenerator] -> ShowS
Show, ColumnGenerator -> ColumnGenerator -> Bool
(ColumnGenerator -> ColumnGenerator -> Bool)
-> (ColumnGenerator -> ColumnGenerator -> Bool)
-> Eq ColumnGenerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ColumnGenerator -> ColumnGenerator -> Bool
== :: ColumnGenerator -> ColumnGenerator -> Bool
$c/= :: ColumnGenerator -> ColumnGenerator -> Bool
/= :: 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
$c== :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
== :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
$c/= :: PrimaryKeyConstraint -> PrimaryKeyConstraint -> Bool
/= :: 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
$cshowsPrec :: Int -> PrimaryKeyConstraint -> ShowS
showsPrec :: Int -> PrimaryKeyConstraint -> ShowS
$cshow :: PrimaryKeyConstraint -> String
show :: PrimaryKeyConstraint -> String
$cshowList :: [PrimaryKeyConstraint] -> ShowS
showList :: [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
$c== :: Constraint -> Constraint -> Bool
== :: Constraint -> Constraint -> Bool
$c/= :: Constraint -> Constraint -> Bool
/= :: 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
$cshowsPrec :: Int -> Constraint -> ShowS
showsPrec :: Int -> Constraint -> ShowS
$cshow :: Constraint -> String
show :: Constraint -> String
$cshowList :: [Constraint] -> ShowS
showList :: [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
$c== :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
== :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
$c/= :: ExcludeConstraintElement -> ExcludeConstraintElement -> Bool
/= :: 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
$cshowsPrec :: Int -> ExcludeConstraintElement -> ShowS
showsPrec :: Int -> ExcludeConstraintElement -> ShowS
$cshow :: ExcludeConstraintElement -> String
show :: ExcludeConstraintElement -> String
$cshowList :: [ExcludeConstraintElement] -> ShowS
showList :: [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
    -- | a IN b
    | InExpression 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
$c== :: Expression -> Expression -> Bool
== :: Expression -> Expression -> Bool
$c/= :: Expression -> Expression -> Bool
/= :: 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
$cshowsPrec :: Int -> Expression -> ShowS
showsPrec :: Int -> Expression -> ShowS
$cshow :: Expression -> String
show :: Expression -> String
$cshowList :: [Expression] -> ShowS
showList :: [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
$c== :: Select -> Select -> Bool
== :: Select -> Select -> Bool
$c/= :: Select -> Select -> Bool
/= :: 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
$cshowsPrec :: Int -> Select -> ShowS
showsPrec :: Int -> Select -> ShowS
$cshow :: Select -> String
show :: Select -> String
$cshowList :: [Select] -> ShowS
showList :: [Select] -> ShowS
Show)

data PostgresType
    = PUUID
    | PText
    | PInt
    | PSmallInt
    | PBigInt
    | PBoolean
    | PTimestampWithTimezone
    | PTimestamp
    | PReal
    | PDouble
    | PPoint
    | PPolygon
    | PDate
    | PBinary
    | PTime
    | PInterval { PostgresType -> Maybe Text
fields :: Maybe Text }
    | 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
$c== :: PostgresType -> PostgresType -> Bool
== :: PostgresType -> PostgresType -> Bool
$c/= :: PostgresType -> PostgresType -> Bool
/= :: 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
$cshowsPrec :: Int -> PostgresType -> ShowS
showsPrec :: Int -> PostgresType -> ShowS
$cshow :: PostgresType -> String
show :: PostgresType -> String
$cshowList :: [PostgresType] -> ShowS
showList :: [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
$c== :: TriggerEventWhen -> TriggerEventWhen -> Bool
== :: TriggerEventWhen -> TriggerEventWhen -> Bool
$c/= :: TriggerEventWhen -> TriggerEventWhen -> Bool
/= :: 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
$cshowsPrec :: Int -> TriggerEventWhen -> ShowS
showsPrec :: Int -> TriggerEventWhen -> ShowS
$cshow :: TriggerEventWhen -> String
show :: TriggerEventWhen -> String
$cshowList :: [TriggerEventWhen] -> ShowS
showList :: [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
$c== :: TriggerEvent -> TriggerEvent -> Bool
== :: TriggerEvent -> TriggerEvent -> Bool
$c/= :: TriggerEvent -> TriggerEvent -> Bool
/= :: 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
$cshowsPrec :: Int -> TriggerEvent -> ShowS
showsPrec :: Int -> TriggerEvent -> ShowS
$cshow :: TriggerEvent -> String
show :: TriggerEvent -> String
$cshowList :: [TriggerEvent] -> ShowS
showList :: [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
$c== :: TriggerFor -> TriggerFor -> Bool
== :: TriggerFor -> TriggerFor -> Bool
$c/= :: TriggerFor -> TriggerFor -> Bool
/= :: 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
$cshowsPrec :: Int -> TriggerFor -> ShowS
showsPrec :: Int -> TriggerFor -> ShowS
$cshow :: TriggerFor -> String
show :: TriggerFor -> String
$cshowList :: [TriggerFor] -> ShowS
showList :: [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
$c== :: PolicyAction -> PolicyAction -> Bool
== :: PolicyAction -> PolicyAction -> Bool
$c/= :: PolicyAction -> PolicyAction -> Bool
/= :: 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
$cshowsPrec :: Int -> PolicyAction -> ShowS
showsPrec :: Int -> PolicyAction -> ShowS
$cshow :: PolicyAction -> String
show :: PolicyAction -> String
$cshowList :: [PolicyAction] -> ShowS
showList :: [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
$c== :: IndexType -> IndexType -> Bool
== :: IndexType -> IndexType -> Bool
$c/= :: IndexType -> IndexType -> Bool
/= :: 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
$cshowsPrec :: Int -> IndexType -> ShowS
showsPrec :: Int -> IndexType -> ShowS
$cshow :: IndexType -> String
show :: IndexType -> String
$cshowList :: [IndexType] -> ShowS
showList :: [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
$c== :: IndexColumn -> IndexColumn -> Bool
== :: IndexColumn -> IndexColumn -> Bool
$c/= :: IndexColumn -> IndexColumn -> Bool
/= :: 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
$cshowsPrec :: Int -> IndexColumn -> ShowS
showsPrec :: Int -> IndexColumn -> ShowS
$cshow :: IndexColumn -> String
show :: IndexColumn -> String
$cshowList :: [IndexColumn] -> ShowS
showList :: [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
$c== :: IndexColumnOrder -> IndexColumnOrder -> Bool
== :: IndexColumnOrder -> IndexColumnOrder -> Bool
$c/= :: IndexColumnOrder -> IndexColumnOrder -> Bool
/= :: 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
$cshowsPrec :: Int -> IndexColumnOrder -> ShowS
showsPrec :: Int -> IndexColumnOrder -> ShowS
$cshow :: IndexColumnOrder -> String
show :: IndexColumnOrder -> String
$cshowList :: [IndexColumnOrder] -> ShowS
showList :: [IndexColumnOrder] -> ShowS
Show)