Postgis - migration from 1.5 to 2.3 - workaround - geometry

Fellows,
I already had a really hard time trying to make a migration from a postgis 1.5 to 2.3. Actually I had many attempts to do that with all version of postgis: 2.0, 2.1, 2.2 and now 2.3.
As I have spent a few weeks with that, and as I am ready to drop that I keep using my old version of postgresql and postgis, I hope my question finds a echo somewhere...
I only want to migrate one table field, a geometry field. So before trying to do that, I would like to hear if any of you have experience with that:
The idea is to select the field from the old postgis (postgresql 9.2, postgis 1.5), and update the table to the new postgis (postgresql 9.6, postgis 2.3).
Anyone can say anything about it?
EDIT---
I have just tryed to import the table I needed, but I got an error:
violation of constraint "enforce_srid_the_geom".
:(
Thanks a lot.

If you need to migrate just a single table with a geometry column and you are getting troubles with the procedure described here http://www.postgis.org/docs/postgis_installation.html#hard_upgrade
I'd suggest a workaround: create a text field in the old db, e.g. wkt_geom, then execute
update tablename set wkt_geom = st_astext(the_geom)
Now drop the geometry column, export the old db and import into the new one. Then, create the geometry column and
update tablename set the_geom = st_geomfromtext(wkt_geom, SRID_HERE)

Related

AWS RDS Postgres PostGIS upgrade problems

I have an RDS instance running Postgres 11.16. I'm trying to upgrade it to 12.11 but it's giving me errors on PostGIS. If I try a "modify" I get the following error in the precheck log file:
Upgrade could not be run on Sun Sep 18 06:05:13 2022
The instance could not be upgraded from 11.16.R1 to 12.11.R1 because of following reasons. Please take appropriate action on databases that have usages incompatible with requested major engine version upgrade and try again.
Following usages in database 'XXXXX' need to be corrected before upgrade:
-- The instance could not be upgraded because there are one or more databases with an older version of PostGIS extension or its dependent extensions (address_standardizer, address_standardizer_data_us, postgis_tiger_geocoder, postgis_topology, postgis_raster) installed. Please upgrade all installations of PostGIS and drop its dependent extensions and try again.
----------------------- END OF LOG ----------------------
First, I tried just removing postgis to upgrade then add it back again. I used: drop extension postgis cascade;. However, this generated the same error
Second, I tried running SELECT postgis_extensions_upgrade();. However, it gives me the following error:
NOTICE: Updating extension postgis_raster from unpackaged to 3.1.5
ERROR: function st_convexhull(raster) does not exist
CONTEXT: SQL statement "ALTER EXTENSION postgis_raster UPDATE TO "3.1.5";"
PL/pgSQL function postgis_extensions_upgrade() line 82 at EXECUTE
SQL state: 42883
Third, I tried to do a manual snapshot and upgrade the snapshot. Same results.
One additional piece of information, I ran SELECT PostGIS_Full_Version(); and this is what it returns:
"POSTGIS=""3.1.5 c60e4e3"" [EXTENSION] PGSQL=""110"" GEOS=""3.7.3-CAPI-1.11.3 b50468f"" PROJ=""Rel. 5.2.0, September 15th, 2018"" GDAL=""GDAL 2.3.1, released 2018/06/22"" LIBXML=""2.9.1"" LIBJSON=""0.12.1"" LIBPROTOBUF=""1.3.0"" WAGYU=""0.5.0 (Internal)"" TOPOLOGY RASTER (raster lib from ""2.4.5 r16765"" need upgrade) (raster procs from ""2.4.4 r16526"" need upgrade)"
As you'll notice, the raster lib is old but I can't really figure out how to upgrade it. I think this is what is causing me problems but I don't know how to overcome it.
I appreciate any thoughts.
I ended up finally giving up on this after many failed attempts. I ended up solving this by:
Spinning up a new instance on the desired postgres version
Using pg_dump on the old version (schema and data)
Using pg_restore on the new version
I'm not sure if I did something wrong with the above but I found my sequences were out of sync on a number of tables. I wrote some scripts to reset the sequence values after doing this. I had to use something like this to re-sync those sequences:
SELECT setval('the_sequence', (SELECT MAX(the_primary_key) FROM the_table)+1);
I wasted enough time and this got me past the issue. Hopefully the next upgrade doesn't give me this much trouble.

how to version multiple tables with dexie 3.0, when users may jump from any previous version to the latest?

After studying the Dexie documentation on versioning, I am unclear about some aspects of versioning using Dexie 3.0.1.
Suppose I have table1 and table2 with only id as an index on each for version 1 of my db:
db.version(1).stores({table1: "++id", table2: "++id"});
For version 2 of my db, I add shoeSize as an index of table1:
db.version(2).stores({table1: "++id,shoeSize"});
For version 3 of my db, I add dateOfBirth as an index of table2.
db.version(3).stores({table2: "++id,dateOfBirth"});
If I understand correctly, for Dexie 3.0, my final code should only have the last change to stores: db.version(3).stores({table2: "++id,dateOfBirth"});. It will NOT have version 2: db.version(2).stores({table1: "++id,shoeSize"});.
So, if a user installs version 1 of my app, then upgrades directly to version 3, how will his table1 get updated to have the shoeSize index? How should I handle versioning multiple tables with Dexie 3.0?

Unable to add cassandra connection

I am trying to add an connection to my cassandra database.
As shown in the examples I added this definition:
#Store(type='cassandra', column.family='StockTable',keyspace='AnalyticsFamily',cassandra.host='localhost')
#IndexBy('volume')
#PrimaryKey('symbol')
define table StockTable (symbol string, price float, volume long);
In the editor I get an red cross as shown in the image below.
Am I missing the cassandra driver on the worker? If yes, how can I add it to the docker image? Or what am I doing wrong?
You have to add the osgi compatible cassandra connectors to {SP_HOME}/lib folder.
Please see https://docs.wso2.com/display/SP4xx/Configuring+Datasources for more details

Cassandra no viable alternative at input Like

I am very new to Cassandra and am trying to use the new LIKE feature but keep getting the error
Line 1: no viable alternative at input 'LIKE'
I am using DataStax DevCenter and am following the examples on https://docs.datastax.com/en/cql/3.3/cql/cql_using/useSASIIndex.html .I am using Cassandra version 3.7.0 and CQL 3.4.2 and the Datastex version is 1.60 community . I have a table named zips with a text field called city that has 10,000 records and am simply using this CQL code
SELECT * FROM "MyTable".zips WHERE city LIKE 'M%';
Before that I added an index using
CREATE CUSTOM INDEX fn_prefix ON "MyTable".zips (city) USING 'org.apache.cassandra.index.sasi.SASIIndex';
I know that the index worked because it allowed me to do this query
SELECT * FROM "Exoler".zips WHERE city='Miami';
without using allow filter and it returns values. Any suggestions would be great as stated I am very new to this.
If you use Cassandra 3.9 and Datastax DevCenter version 1.5.0 or 1.6.0 it won't support LIKE (atleast on Windows). The result is only "no viable alternative at input 'LIKE'"
But it works fine if you use command prompt:
WINDOWS-Key
cmd
"%CASSANDRA_HOME%\bin\cqlsh"
It is just a bug in Datastax DevCenter I guess.

int object has no attribute replace when trying to run a CQL command in cassandra

I have a counter column family in cassandra. When i try to view the data from CQL i get an error even though there is data in the column family.
SELECT * from userstats;
Generates the following error:
'int' object has no attribute 'replace'
I can confirm that the data is in the column family and is working properly since I can view the data with the Datastax Opscenter data explorer.
It sounds like you're using an older version of cqlsh. Upgrading it (just copying the bin/cqlsh file from the Cassandra 1.1 branch head, along with everything under the pylib directory, into place) ought to solve this.
If it doesn't, running cqlsh with --debug would help a lot in diagnosing the problem.

Resources