Skip to content

Commit befa88b

Browse files
committed
Updating the sequencing data and removing steward table updates.
1 parent 21685ce commit befa88b

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

connect_remote.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
file = open(newFile)
137137
textCheck = copy.deepcopy(file.read())
138138
serverFun = copy.deepcopy(record[3])
139-
textCheck = re.sub('[\s+\t+\n+\r+]', '', textCheck)
140-
serverFun = re.sub('[\s+\t+\n+\r+]', '', serverFun)
139+
textCheck = re.sub(r'[\s+\t+\n+\r+]', '', textCheck)
140+
serverFun = re.sub(r'[\s+\t+\n+\r+]', '', serverFun)
141141
match = serverFun == textCheck
142142
# Pushing (to the db) and pulling (from the db) are defined by the user
143143
if match is False:
@@ -228,8 +228,22 @@
228228
print(schema + "." + functs.split(".")[0] + " has "
229229
+ str(cur.rowcount) + " definitions.")
230230

231-
conn.close()
231+
print('Running the indexes:')
232+
233+
# This section makes sure that the sequences are reset properly. We ran into
234+
# this issue unintentionally during a re-load of the Neotoma data.
235+
cur.execute(open('helpers/reset_sequences.sql', 'r').read())
236+
cur2 = conn.cursor()
232237

238+
for res in cur.fetchall():
239+
try:
240+
cur2.execute(res[0])
241+
conn.commit()
242+
except Exception as e:
243+
print('skipped: ' + res[0])
244+
print(e)
245+
246+
conn.close()
233247

234248
print("The script has rewritten:")
235249

function/ts/deletesynonymy.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@ CREATE OR REPLACE FUNCTION ts.deletesynonymy(_synonymyid integer, _contactid int
44
AS $function$
55
DELETE FROM ndb.synonymy AS sy
66
WHERE sy.synonymyid = _synonymyid;
7-
8-
INSERT INTO ti.stewardupdates(contactid, tablename, pk1, operation)
9-
VALUES (_contactid, n'synonymy', _synonymyid, n'delete')
107
$function$

function/ts/insertsample.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
CREATE OR REPLACE FUNCTION ts.insertsample(_analysisunitid integer, _datasetid integer, _samplename character varying DEFAULT NULL::character varying, _sampledate character varying DEFAULT NULL::character varying, _analysisdate character varying DEFAULT NULL::character varying, _taxonid integer DEFAULT NULL::integer, _labnumber character varying DEFAULT NULL::character varying, _prepmethod character varying DEFAULT NULL::character varying, _notes character varying DEFAULT NULL::character varying)
1+
CREATE OR REPLACE FUNCTION ts.insertsample(_analysisunitid integer,
2+
_datasetid integer,
3+
_samplename character varying DEFAULT NULL::character varying,
4+
_sampledate character varying DEFAULT NULL::character varying,
5+
_analysisdate character varying DEFAULT NULL::character varying,
6+
_taxonid integer DEFAULT NULL::integer,
7+
_labnumber character varying DEFAULT NULL::character varying,
8+
_prepmethod character varying DEFAULT NULL::character varying,
9+
_notes character varying DEFAULT NULL::character varying)
210
RETURNS integer
311
LANGUAGE sql
412
AS $function$

helpers/reset_sequences.sql

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
/* Code from here: */
12
SELECT 'select '
23
|| trim(trailing ')'
34
from replace(pg_get_expr(d.adbin, d.adrelid),
45
'nextval', 'setval'))
56
|| ', (select max( ' || a.attname || ') from only '
67
|| nspname || '.' || relname || '));'
78
FROM pg_class c
8-
JOIN pg_namespace n on n.oid = c.relnamespace
9-
JOIN pg_attribute a on a.attrelid = c.oid
10-
JOIN pg_attrdef d on d.adrelid = a.attrelid
11-
and d.adnum = a.attnum
12-
and a.atthasdef
13-
WHERE relkind = 'r' and a.attnum > 0
14-
and pg_get_expr(d.adbin, d.adrelid) ~ '^nextval';
9+
JOIN pg_namespace n ON n.oid = c.relnamespace
10+
JOIN pg_attribute a ON a.attrelid = c.oid
11+
JOIN pg_attrdef d ON d.adrelid = a.attrelid
12+
AND d.adnum = a.attnum
13+
AND a.atthasdef
14+
WHERE relkind = 'r' and a.attnum > 0
15+
AND pg_get_expr(d.adbin, d.adrelid) ~ '^nextval';

0 commit comments

Comments
 (0)