stabilize new DB schema
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 7 Aug 2009 12:47:02 +0000 (12:47 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 7 Aug 2009 12:47:02 +0000 (12:47 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@316 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

wob/audit.wolf
wob/basics.wolf
wob/cart.wolf
wob/customer.wolf
wob/event.wolf
wob/magicsmoke.wolf
wob/order.wolf
wob/user.wolf

index 94395a9..af255b3 100644 (file)
@@ -11,7 +11,7 @@
        <Table name="moneylog" backup="yes">
                <Column name="logid" type="seq64" primarykey="yes"/>
                <Column name="logtime" type="int64" notnull="yes"/>
-               <Column name="uname" type="string:64" foreignkey="users:uname" null="yes"/>
+               <Column name="uname" type="string:64" foreignkey="user:uname" null="yes"/>
                <Column name="orderid" type="int32" foreignkey="order:orderid" null="yes"/>
                <Column name="voucherid" type="string:32" foreignkey="voucher:voucherid" null="yes"/>
                <Column name="moved" type="int32" notnull='yes'/>
                <Column name="vouchervalue" type="int32" null="yes"/>
                <Column name="log" type="string" notnull='yes'/>
        </Table>
+       
+       <Table name="documentlog" backup="yes">
+               <Column name="docid" type="seq64" primarykey="yes"/>
+               <Column name="logtime" type="int64" notnull="yes"/>
+               <Column name="uname" type="string:64" foreignkey="user:uname" null="yes"/>
+               <Column name="orderid" type="int32" foreignkey="order:orderid" null="yes"/>
+               <Column name="doctype" type="string:32" notnull="yes"/>
+               <Column name="docbody" type="blob" notnull="yes"/>
+       </Table>
 </Wolf>
\ No newline at end of file
index 37a76ee..e59db60 100644 (file)
@@ -17,6 +17,8 @@
                <Preset><V col="ckey" val="SaleStop"/><V col="cval" val="0"/></Preset>
                <Preset><V col="ckey" val="TicketIDChars"/><V col="cval" val="10"/></Preset>
                <Preset><V col="ckey" val="VoucherIDChars"/><V col="cval" val="10"/></Preset>
+               <Preset><V col="ckey" val="Flag admin"/><V col="cval" val="User is Admin"/></Preset>
+               <Preset><V col="ckey" val="Flag web"/><V col="cval" val="User is Customer"/></Preset>
        </Table>
        
        
@@ -25,5 +27,7 @@
                <Column name="description" type="string"/>
                <Column name="content" type="blob"/>
                <Column name="hash" type="string:32" notnull="yes"/> <!--md5-->
+               <Column name="dolog" type="bool" default="0"/>
+               <Column name="flags" type="string"/>
        </Table>
 </Wolf>
index 4c8ee2e..641931c 100644 (file)
@@ -22,6 +22,7 @@
                <!--tickets in the cart-->
                <Column name="eventid" type="int32" notnull="yes" foreignkey="event:eventid" primarykey="yes"/>
                <Column name="amount" type="int32" notnull="yes"/>
+               <Column name="seating" type="string:32" null="yes"/>
        </Table>
        <Table name="cart_voucher">
                <Column name="cvid" type="seq64" primarykey="yes"/>
                <!--voucher value-->
                <Column name="value" type="int32" notnull="yes"/>
        </Table>
+       <Table name="cart_item">
+               <Column name="ciid" type="seq64" primarykey="yes"/>
+               <Column name="cartid" type="string:32" notnull="yes" foreignkey="cart:cartid"/>
+               <Column name="productid" type="int32" foreignkey="product:productid" notnull="yes"/>
+               <Column name="amount" type="int32" notnull="yes"/>
+       </Table>
        
        <Table name="websession">
                <Column name="sessionid" type="string:64" primarykey="yes"/>
index e68c10d..9f16c2b 100644 (file)
        </Table>
        <Table name="customer" backup="yes">
                <Column name="customerid" type="seq32" primarykey="yes"/>
-               //contact data
+               <!--main data-->
+               <Column name="title" type="string" notnull="yes"/>
+               <Column name="firstname" type="string" notnull="yes"/>
                <Column name="name" type="string" notnull="yes"/>
-               <Column name="contact" type="string"/> <!-- //phone or something -->
                <Column name="comments" type="text"/>
-               //online login data
+               <Column name="flags" type="string"/>
+               <!--online login data-->
                <Column name="email" type="string" null="yes"/>
                <Column name="passwd" type="string:64" null="yes"/> <!-- salted SHA-1 hash of passwd -->
        </Table>
        <Table name="address" backup="yes">
                <Column name="addressid" type="seq64" primarykey="yes"/>
                <Column name="customerid" type="int32" foreignkey="customer:customerid" notnull="yes"/>
-               <Column name="name" type="string" null="yes"/>
-               <Column name="company" type="string" null="yes"/>
+               <Column name="lastused" type="int64" null="yes"/>
+               <Column name="name" type="string" notnull="yes"/>
                <Column name="addr1" type="string" notnull="yes"/>
                <Column name="addr2" type="string" null="yes"/>
                <Column name="city" type="string:64" notnull="yes"/>
                <Column name="state" type="string:32" null="yes"/>
                <Column name="zipcode" type="string:32" notnull="yes"/>
-               <Column name="country" type="string:3" notnull="yes" foreignkey="country:countryid"/>
-               <Column name="deleted" type="bool" notnull="yes" default="0"/>
+               <Column name="countryid" type="string:3" notnull="yes" foreignkey="country:countryid"/>
+               <Column name="isdeleted" type="bool" notnull="yes" default="0"/>
+       </Table>
+       <Table name="contacttype" backup="yes">
+               <Column name="contacttypeid" type="seq32" primarykey="yes"/>
+               <Column name="contacttype" type="string:64" notnull="yes"/>
+               <Column name="uriprefix" type="string:10" null="yes"/>
+       </Table>
+       <Table name="contact" backup="yes">
+               <Column name="contactid" type="seq64" primarykey="yes"/>
+               <Column name="customerid" type="int32" foreignkey="customer:customerid" notnull="yes"/>
+               <Column name="contacttypeid" type="int32" notnull="yes" foreignkey="contacttype:contacttypeid"/>
+               <Column name="contact" type="string" notnull="yes"/>
        </Table>
        
        <Class name="Country">
                <Property name="id" type="astring"/>
                <Property name="name" type="astring"/>
-               <ToXml name="Full">id name</ToXml>
        </Class>
        <Class name="Address">
                <Property name="addressid" type="int64"/>
                <Property name="state" type="string"/>
                <Property name="zipcode" type="string"/>
                <Property name="countryid" type="astring"/>
-               <Property name="deleted" type="bool"/>
+               <Property name="isdeleted" type="bool"/>
                
                <Property name="country" type="Country"/>
                
-               <ToXml name="Full">addressid customerid name company addr1 addr2 city state zipcode countryid deleted country/Full</ToXml>
+       </Class>
+       <Class name="ContactType">
+               <Property name="contacttypeid" type="int32"/>
+               <Property name="contacttype" type="string"/>
+               <Property name="uriprefix" type="string"/>
+       </Class>
+       <Class name="Contact">
+               <Property name="contactid" type="int64"/>
+               <Property name="customerid" type="int32"/>
+               <Property name="contacttypeid" type="int32"/>
+               <Property name="contact" type="string"/>
+               
+               <Property name="contacttype" type="ContactType"/>
        </Class>
        <Class name="Customer">
                <Property name="id" type="int"/>
                <Property name="name" type="string"/>
-               <Property name="contact" type="string"/>
                <Property name="comments" type="string"/>
-               //online login data
+               <!--online login data-->
                <Property name="email" type="string"/>
                <Property name="passwd" type="string"/>
                
                <Property name="addresses" type="List:Address"/>
-               <ToXml name="Full">id name contact comments email passwd addresses/Full</ToXml>
-               <ToXml name="Short">id name</ToXml>
+               <Property name="contacts" type="List:Contact"/>
+       </Class>
+       <Class name="CustomerShort">
+               <Property name="id" type="int"/>
+               <Property name="name" type="string"/>
        </Class>
        
        <Transaction name="GetCustomer">
                        <Var name="customerid" type="int"/>
                </Input>
                <Output>
-                       <Var name="customer" type="Customer/Full"/>
+                       <Var name="customer" type="Customer"/>
                </Output>
        </Transaction>
        
        <Transaction name="GetAllCustomerNames">
                <Input/>
                <Output>
-                       <Var name="customers" type="List:Customer/Short"/>
+                       <Var name="customers" type="List:CustomerShort"/>
                </Output>
        </Transaction>
 </Wolf>
\ No newline at end of file
index 2f1bcc2..2ebf21c 100644 (file)
               <Column name="description" type="text"/>
        </Table>
        
+       <Table name="seatplan" backup="yes">
+               <Column name="seatplanid" type="seq32" primarykey="yes"/>
+               <!-- display name -->
+               <Column name="name" type="string"/>
+               <!-- XML form of the plan -->
+               <Column name="plan" type="text"/>
+       </Table>
+       
+       <Table name="pricecategory" backup="yes">
+               <Column name="pricecategoryid" type="seq32" primarykey="yes"/>
+               <Column name="name" type="string" notnull="yes"/>
+               <Column name="abbreviation" type="string:10" notnull="yes"/>
+               <Column name="formula" type="string"/>
+               <Column name="flags" type="string"/>
+               
+               <Preset><V col="name" val="Normal"/><V col="abbreviation" val="norm"/></Preset>
+       </Table>
+       
+       <Table name="artist" backup="yes">
+               <Column name="artistid" type="seq32" primarykey="yes"/>
+               <Column name="artistname" type="string" notnull="yes"/>
+               <Column name="description" type="text"/>
+               <Column name="comment" type="text"/>
+       </Table>
+       
        <Table name="event" backup="yes">
                <Column name="eventid" type="seq32" primarykey="yes"/>
                <!--display data-->
                <Column name="title" type="string" notnull="yes"/>
                <Column name="artist" type="string" notnull="yes"/>
-               <Column name="description" type="text"/>
+               <Column name="description" type="text"/><!-- web visible -->
+               <Column name="comment" type="text"/><!-- internal -->
                <!--timing and location-->
                <Column name="starttime" type="int64" notnull="yes"/>
                <Column name="endtime" type="int64" notnull="yes"/>
                <Column name="roomid" type="string:64" foreignkey="room:roomid"/>
+               <Column name="seatplanid" type="int32" foreignkey="seatplan:seatplanid" null="yes"/>
                <!--initially a copy from room, can be adjusted-->
                <Column name="capacity" type="int32" notnull="yes"/>
-               <!--default pricing in cents-->
-               <Column name="defaultprice" type="int32" notnull="yes"/>
-               <!--if not null/empty: event has been cancelled-->
+               <!-- flags -->
+               <Column name="iscancelled" type="bool" default="0"/>
+               <Column name="flags" type="string"/>
+               <Column name="tax" type="int32"/>
+               <!-- reason the event has been cancelled-->
                <Column name="cancelreason" type="string"/>
        </Table>
        
+       <Table name="eventprices" backup="yes">
+               <Column name="eventid" type="int32" primarykey="yes" foreignkey="event:eventid"/>
+               <Column name="pricecategoryid" type="int32" primarykey="yes" foreignkey="pricecategory:pricecategoryid"/>
+               <Column name="maxavailable" type="int32" notnull="yes"/>
+               <Column name="price" type="int32" notnull="yes"/>
+               <Column name="flags" type="string"/>
+       </Table>
+       
        <Class name="Event">
                <Property name="id" type="int" id="yes"/>
                <Property name="start" type="int64"/>
                <Property name="amountSold" type="int"/>
                <Property name="amountReserved" type="int"/>
                <Property name="description" type="string"/>
-               <ToXml name="Full">id start end capacity defaultprice cancelled title artist room cancelreason description</ToXml>
        </Class>
        
        <Class name="Room">
               <Property name="id" type="string"/>
               <Property name="capacity" type="int"/>
               <Property name="description" type="string"/>
-              <ToXml name="Full">id capacity description</ToXml>
        </Class>
        
        <Transaction name="GetEvent">
index 0e90d05..4d359cf 100644 (file)
@@ -10,7 +10,7 @@
        <!-- generic settings -->
        <Project baseDir=".." wobDir="wob" name="MagicSmoke"/>
        <Version comm="0100" needcomm="0100" humanReadable="1.1 alpha" svnTarget="."/>
-       <DataBase instance="db" schema="dbScheme" version="00.03"/>
+       <DataBase instance="db" schema="dbScheme" version="01.04"/>
        
        <!-- configure output -->
        <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" classPrefix="M" clean="yes"/>
index 5da609c..50fd0d4 100644 (file)
@@ -10,8 +10,7 @@
        <Table name="shipping" backup="yes">
               <Column name="shipid" type="seq32" primarykey="yes"/>
               <Column name="cost" type="int32" notnull="yes"/> <!--default cost of this shipping type-->
-              <Column name="canuseweb" type="bool" default="false"/> <!--is offered on web interface-->
-              <Column name="canallusers" type="bool" default="true"/> <!--all GUI users may select it-->
+              <Column name="flags" type="string"/>
               <Column name="description" type="string"/> <!--description for the shipping type-->
        </Table>
        <Table name="order" backup="yes">
                <!--customer-->
                <Column name="customerid" type="int32" foreignkey="customer:customerid"/>
                <!--seller (_online for web forms)-->
-               <Column name="soldby" type="string:64" foreignkey="users:uname"/>
+               <Column name="soldby" type="string:64" foreignkey="user:uname"/>
                <!--if not null/empty: this address for delivery, customer address for invoice-->
-               <Column name="deliveryaddress" type="text"/>
-               <!--if not null/empty: lodge/deposit the tickets at a seller with _deposit flag-->
-               <Column name="depositat" type="string:64" foreignkey="users:uname"/>
+               <Column name="invoiceaddress" type="int64" foreignkey="address:addressid" notnull="yes"/>
+               <Column name="deliveryaddress" type="int64" foreignkey="address:addressid" null="yes"/>
                <!--status, see ORDER_* constants-->
                <Column name="status" type="enum32" notnull="yes">
                        <Value name="Placed" value="0"/>
                <Column name="eventid" type="int32" foreignkey="event:eventid"/>
                <!--initially a copy from event, can be adjusted by seller-->
                <Column name="price" type="int32" notnull="yes"/>
+               <Column name="pricecategoryid" type="int32" foreignkey="pricecategory:pricecategoryid"/>
                <!--status of ticket (see TICKET_* constants)-->
                <Column name="status" type="enum32" notnull="yes">
-                       <Value name="Reserved" value="0x301"/> <!--dec: 769-->
-                       <Value name="Bought" value="0x302"/> <!--dec: 770-->
+                       <Value name="Reserved" value="0x311"/> <!--dec: 785-->
+                       <Value name="Ordered" value="0x312"/> <!--dec: 786-->
                        <Value name="Used" value="0x303"/> <!--dec: 771-->
                        <Value name="Cancelled" value="0x4"/> <!--dec: 4-->
                        <Value name="Refund" value="0x4"/>
                        <Value name="MaskBlock" value="0x100"/> <!--dec: 256-->
                        <Value name="MaskPay" value="0x200"/> <!--dec: 512-->
                        <Value name="MaskUsable" value="0x300"/> <!--dec: 768-->
-
+                       <Value name="MaskReturnable" value="0x10"/> <!--dec: 16-->
                </Column>
                <Column name="orderid" type="int32" foreignkey="order:orderid" notnull="yes"/>
+               <Column name="seat" type="string:32"/>
+               
+               <!-- TODO: add check constraint that eventid,pricecategoryid exist in eventprice-->
        </Table>
        <Table name="voucher" backup="yes" base="BarcodeTable">
                <!--a 8-32 char code (code39: case-insensitive letters+digits) for the voucher-->
                <!--remaining value in cents (0 for cancelled)-->
                <Column name="value" type="int32" notnull="yes"/>
        </Table>
+       
+       <Table name="product" backup="yes">
+               <Column name="productid" type="seq32" primarykey="yes"/>
+               <Column name="name" type="string" notnull="yes"/>
+               <Column name="description" type="text"/>
+               <!-- amount that is in the inventory, or -1 if it is unlimited -->
+               <Column name="inventory" type="int32" notnull="yes"/>
+               <Column name="price" type="int32" notnull="yes"/>
+               <Column name="barcode" type="string" null="yes"/>
+               <Column name="flags" type="string"/>
+               <Column name="tax" type="int32"/>
+       </Table>
+       <Table name="item" backup="yes">
+               <Column name="itemid" type="seq64" primarykey="yes"/>
+               <Column name="productid" type="int32" foreignkey="product:productid" notnull="yes"/>
+               <Column name="orderid" type="int32" foreignkey="order:orderid" notnull="yes"/>
+               <Column name="amount" type="int32" notnull="yes"/>
+               <Column name="totalprice" type="int32" notnull="yes"/>
+       </Table>
 
        
        
index c8a9544..8b7a753 100644 (file)
@@ -9,38 +9,56 @@
 <Wolf>
        <Table name="host" backup="yes">
                <Column name="hostname" type="string:64" primarykey="yes"/>
-               <!-- if hostkey is NULL it is a special host (_any, _anon, _online) -->
+               <!-- if hostkey is NULL it is a special host (_any), otherwise the key is a sha1 hash of the real key -->
                <Column name="hostkey" type="string" />
                
                <Preset><V col="hostname" code='translate("SpecialHost","_any")'/></Preset>
-               <Preset><V col="hostname" code='translate("SpecialHost","_anon")'/></Preset>
-               <Preset><V col="hostname" code='translate("SpecialHost","_online")'/></Preset>
        </Table>
        
-       <Table name="users" backup="yes">
+       <Table name="user" backup="yes">
                <Column name="uname" type="string:64" primarykey="yes"/>
+               <!-- passwd is a salted sha1 hash -->
                <Column name="passwd" type="string" notnull="yes"/>
                <!-- more detailed data that can be displayed to admins -->
                <Column name="description" type="text"/>
+               <Column name="flags" type="string"/>
+       </Table>
+       
+       <Table name="role" backup="yes">
+               <Column name="rolename" type="string:64" primarykey="yes"/>
+               <Column name="description" type="text"/>
+               <Column name="flags" type="string"/>
+               
+               <Preset>
+                       <V col="rolename" val="_admin"/>
+                       <V col="description" val="Admin Users"/>
+                       <V col="flags" val="admin"/>
+               </Preset>
+               <Preset>
+                       <V col="rolename" val="_web"/>
+                       <V col="description" val="Web Interface, Customers"/>
+                       <V col="flags" val="web"/>
+               </Preset>
+       </Table>
+       
+       <Table name="rolerights" backup="yes">
+               <Column name="rolename" type="string:64" primarykey="yes"/>
+               <Column name="rightname" type="string:64" primarykey="yes"/>
        </Table>
        
        <Table name="userrole" backup="yes">
-               <Column name="uname" type="string:64" notnull="yes" foreignkey="users:uname" index="yes" primarykey="yes"/>
-               <Column name="role" type="string:32" notnull="yes" primarykey="yes"/>
+               <Column name="uname" type="string:64" notnull="yes" foreignkey="user:uname" index="yes" primarykey="yes"/>
+               <Column name="role" type="string:64" notnull="yes" primarykey="yes" foreignkey="role:rolename"/>
        </Table>
        
-       <Table name="userhosts" backup="yes">
-               <Column name="uname" type="string:64" notnull="yes" foreignkey="users:uname" index="yes" primarykey="yes"/>
+       <Table name="userhost" backup="yes">
+               <Column name="uname" type="string:64" notnull="yes" foreignkey="user:uname" index="yes" primarykey="yes"/>
                <Column name="host" type="string:64" notnull="yes" foreignkey="host:hostname" primarykey="yes"/>
        </Table>
        
        <Table name="session">
                <Column name="sessionid" type="string:64" primarykey="yes"/>
-               <!-- if empty: not authenticated -->
-               <Column name="user" type="string:64"/>
-               <!-- used during authentication; emptied after authentication: -->
-               <Column name="hchallenge" type="string:64"/>
-               <Column name="uchallenge" type="string:64"/>
+               <Column name="user" type="string:64" notnull="yes" foreignkey="user:uname"/>
                <!-- unix timestamp at which to delete this session -->
                <Column name="timeout" type="int64" notnull="yes"/>
        </Table>
                <Input>
                        <Var name="username" type="string"/>
                        <Var name="password" type="string"/>
+                       <Var name="hostname" type="string"/>
+                       <Var name="hostkey" type="string"/>
                </Input>
                <Output>
                        <Var name="sessionid" type="string"/>
+                       <Var name="validtill" type="int64"/>
                </Output>
        </Transaction>
        
        
        <Class name="User">
                <Property name="name" type="astring"/>
-               <Property name="password" type="string"/>
                <Property name="description" type="string"/>
-               
-               <ToXml name="Full">name password description</ToXml>
-               <ToXml name="NoPwd">name description</ToXml>
        </Class>
        
        <Class name="Host">
                <Property name="name" type="string"/>
                <!-- if hostkey is NULL it is a special host (_any, _anon, _online) -->
                <Property name="key" type="string" />
-               <ToXml name="Full">name key</ToXml>
        </Class>
        
        <Transaction name="GetAllUsers">
                <Input/>
                <Output>
-                       <Var name="users" type="List:User/NoPwd"/>
+                       <Var name="users" type="List:User"/>
                </Output>
        </Transaction>
        
                <Input>
                        <Var name="username" type="astring"/>
                        <Var name="password" type="string"/>
+                       <Var name="description" type="string"/>
                </Input>
                <Output>
-                       <Var name="user" type="User/Full"/>
+                       <Var name="user" type="User"/>
                </Output>
        </Transaction>
        
                </Input>
        </Transaction>
        
-       <Class name="UserRole">
-               <Property name="username" type="astring"/>
-               <Property name="isset" type="bool"/>
-               <ToXml name="Full">username isset</ToXml>
-       </Class>
-       
        <Transaction name="GetUserRoles">
                <Input>
                        <Var name="username" type="astring"/>
                </Input>
                <Output>
-                       <Var name="roles" type="List:UserRole/Full"/>
+                       <Var name="roles" type="List:string"/>
+                       <Var name="rights" type="List:astring"/>
                </Output>
        </Transaction>
        
        <Transaction name="SetUserRoles">
                <Input>
                        <Var name="username" type="astring"/>
-                       <Var name="roles" type="List:UserRole/Full"/>
+                       <Var name="roles" type="List:string"/>
                </Input>
                <Output/>
        </Transaction>
        <Transaction name="GetAllHosts">
                <Input/>
                <Output>
-                       <Var name="hosts" type="List:Host/Full"/>
+                       <Var name="hosts" type="List:Host"/>
                </Output>
        </Transaction>
        
                <Output/>
        </Transaction>
        
-       <Class name="HostAcl">
-               <Property name="hostname" type="astring"/>
-               <Property name="isset" type="bool"/>
-               <ToXml name="Full">hostname isset</ToXml>
-       </Class>
-       
        <Transaction name="GetUserHosts">
                <Input>
                        <Var name="username" type="astring"/>
                </Input>
                <Output>
-                       <Var name="hosts" type="List:HostAcl/Full"/>
+                       <Var name="hosts" type="List:astring"/>
                </Output>
        </Transaction>
        
        <Transaction name="SetUserHosts">
                <Input>
                        <Var name="username" type="astring"/>
-                       <Var name="hosts" type="List:HostAcl/Full"/>
+                       <Var name="hosts" type="List:astring"/>
                </Input>
                <Output/>
        </Transaction>