Browse Source

current schema

Brennen Bearnes 7 months ago
parent
commit
fb8be75add
1 changed files with 24 additions and 9 deletions
  1. 24
    9
      lib/App/Pieces.pm

+ 24
- 9
lib/App/Pieces.pm View File

@@ -102,22 +102,27 @@ sub create_pieces_db {
102 102
   my ($self) = shift;
103 103
   my ($dbh) = @_;
104 104
 
105
-  $dbh->do(q{
106
-    CREATE TABLE pieces (
105
+  # We'll stash what version of pieces created the schema, and when:
106
+  $dbh->do(qq{
107
+    CREATE TABLE schema_version (
107 108
       id integer primary key,
108
-      address text,
109
-      created text
109
+      version text DEFAULT '$VERSION',
110
+      created text DEFAULT CURRENT_TIMESTAMP
110 111
     );
111 112
   });
112 113
 
114
+  $dbh->do(q{ INSERT INTO schema_version DEFAULT VALUES; });
115
+
113 116
   $dbh->do(q{
114
-    CREATE TABLE schema_version (
117
+    CREATE TABLE pieces (
115 118
       id integer primary key,
116
-      version text,
117
-      created text
119
+      address text,
120
+      created text,
121
+      modified text
118 122
     );
119 123
   });
120 124
 
125
+
121 126
   $dbh->do(q{
122 127
     CREATE TABLE links (
123 128
       id integer primary key,
@@ -127,6 +132,16 @@ sub create_pieces_db {
127 132
       created text
128 133
     );
129 134
   });
135
+
136
+  $dbh->do(q{
137
+    CREATE TABLE groups (
138
+      id integer primary key,
139
+      name text,
140
+      description text,
141
+      created text,
142
+      modifed text
143
+    );
144
+  });
130 145
 }
131 146
 
132 147
 =item add(@addresses)
@@ -187,7 +202,7 @@ sub get_or_add {
187 202
 
188 203
   # If we didn't find an existing piece, add it and get its id
189 204
   if (! defined $id) {
190
-    ($id) = add($addy);
205
+    ($id) = $self->add($addy);
191 206
   }
192 207
 
193 208
   return $id;
@@ -267,7 +282,7 @@ sub foreach_row {
267 282
 
268 283
 Copyright 2018 Brennen Bearnes
269 284
 
270
-    mark is free software; you can redistribute it and/or modify
285
+    pieces is free software; you can redistribute it and/or modify
271 286
     it under the terms of the GNU General Public License as published by
272 287
     the Free Software Foundation; either version 2 of the License, or
273 288
     (at your option) any later version.

Loading…
Cancel
Save