PostgreSql migration error - asp.net

I have aspnet zero project and trying to use it with the Postgresql. I followed the instructions and when i tried to Update-Database it gaves me error:
Failed executing DbCommand (18ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
CREATE SEQUENCE "AppSubscriptionPayments_Id_seq" START WITH 1 INCREMENT BY 1
NO MINVALUE NO MAXVALUE NO CYCLE;
ALTER TABLE "AppSubscriptionPayments" ALTER COLUMN "Id" TYPE int8;
ALTER TABLE "AppSubscriptionPayments" ALTER COLUMN "Id" SET NOT NULL;
ALTER TABLE "AppSubscriptionPayments" ALTER COLUMN "Id" SET DEFAULT
(nextval('"AppSubscriptionPayments_Id_seq"'));
ALTER SEQUENCE "AppSubscriptionPayments_Id_seq" OWNED BY
"AppSubscriptionPayments"."Id"
42P01: "AppSubscriptionPayments" object is not exists
I'm Using Postgresql 10, Visual Studio 2017 and ASPNET Zero.

Delete all existing migrations and Add-Migration from scratch.
Be sure there's not an existing database (that specified in the connection string) while you add-migrations. If you have an already created database before, migrations cannot be built correctly.
https://aspnetboilerplate.com/Pages/Documents/EF-Core-PostgreSql-Integration

Related

Package Manager Console not allowed to drop Index

I am trying to update my database to a new migration, but it gets stuck on a part where it needs to drop an index. It says: Cannot drop the index 'Player.IX_Player_OrganizationId1', because it does not exist or you do not have permission.
What I am doing is the following:
I open my package manager and run the command: add-migration [name]
Then I run the command: update-database
Then in proceeds to do some tings, altough its gets stuck on the command:
Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
DROP INDEX [IX_Player_OrganizationId1] ON [Player]; Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text',
CommandTimeout='30'] DROP INDEX [IX_Player_OrganizationId1] ON
[Player]; Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot
drop the index 'Player.IX_Player_OrganizationId1', because it does not
exist or you do not have permission.
So what i did was checking if the index is there, i did this with the sp_help player command in an SQL Query. This shows the following:
index_name
PK_Player
Player.IX_Player_OrganizationId1
So it does exist, which means i do not have permission to drop it. So then I runned the SQL query
Drop INDEX "Player.IX_Player_OrganizationId1"
on Player
Which did the job, but my data is not showing correctly in the web application (ASP.NET MVC)
I think this is because i didnt use a migration to update it, but i am not sure. Can anyone help me with either making sure the migration succeeds/giving the PM Console permissions or make sure the data shows correclty in my ASP.NET application.
Thank you in advance!
NOTE: using nuget.org package & Microsoft Visual Studio Offline Packagaes
I have solved this problem; I manually added the index using "indexname", where it should have been [indexname].

Run PDO SQLite Query On In-Memory Database On Github Actions

I use PHPUnit to test by PDO wrapper. One of my tests is an integration test that proves that the abstraction layer produces the right syntax, or binds PDOStatement in the right way, etc. For this, I use an in-memory SQLite database, and declare ext-pdo_sqlite as a dev-dependency of my project.
When Github Actions runs a build, dependencies all get installed, hinting that pdo_sqlite is present on the system. This is further confirmed by the fact that the connection succeeds. However, when I run an insert query to set up my database, I get the following error:
PDOException: SQLSTATE[HY000]: General error: 1 no such column: TRUE
The query looks like this:
INSERT INTO `persons` (`id`, `name`, `dob`, `weight`, `is_dev`, `teeth`) VALUES (NULL, 'Anton', '1987-11-03', 71.3, TRUE, 31)
Table creation is done with PDO like this:
$pdo->exec("CREATE TABLE `$tableName` (`id` int(6) PRIMARY KEY, `name` varchar(255), `dob` datetime, `weight` float(5), `is_dev` bool, `teeth` int(2))");
This only manifests on CI, and local tests pass fine - even on the same PHP version as CI.
Any ideas? Am I just missing something in the syntax? Could it be that GH Actions has only a dummy implementation of SQLite or something?
Note: This is an open source project, and you can see everything, including the failing build, in dhii/pdo-query#1.

lein run migration doesn't create a database

when trying to migrate the following files,
drop table test2;
CREATE TABLE test2
(id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(30),
message VARCHAR(200),
timestamp TIMESTAMP(7));
I got the following result:
2019-12-07 10:54:33,129 [main] INFO migratus.core - Starting migrations
2019-12-07 10:54:33,253 [main] DEBUG migratus.migrations - Looking for migrations in #object[java.io.File 0x4f880f4a /home/jonas/Dropbox/prog/web/clojure/test2/resources/migrations]
2019-12-07 10:54:33,258 [main] INFO migratus.core - Ending migrations
It seems that it doesn't find the connection and therefore no database is created. Could that be the case?
found the solution, set the DATABASE_URL to the corresponding database:
export DATABASE_URL="jdbc:sqlite:./test2.db"
where test2 is the name of the app and sqlite is the name of the database

Errno 121 on restoring mysqldump to empty DB

One of our MariaDB users decided to copy a database via a shell script that pipes the output of a mysqldump to another table.
If you restore the mysqldump to a database that hasn't been created before, it works just fine. However, if you then drop that database, re-create it, and then try to run the script again, it throws the following error:
ERROR 1005 (HY000) at line 25: Can't create table
core_dev.addresses (errno: 121 "Duplicate key on write or update")
mysqldump: Got errno 32 on write
SHOW ENGINE INNODB STATUS yields the following insight:
2017-05-03 09:34:19 7f9929fb4b00 Error in foreign key constraint
creation for table core_dev.addresses. A foreign key constraint of
name core_dev.addresses_ibfk_2 already exists. (Note that
internally InnoDB adds 'databasename' in front of the user-defined
constraint name.) Note that InnoDB's FOREIGN KEY system tables store
constraint names as case-insensitive, with the MySQL standard
latin1_swedish_ci collation. If you create tables or databases whose
names differ only in the character case, then collisions in constraint
names can occur. Workaround: name your constraints explicitly with
unique names.
However, the core_dev database is entirely empty:
MariaDB [(none)]> SHOW TABLES IN core_dev;
Empty set (0.01 sec)
What could the problem be? I'm not able to replicate this problem on any of our other MariaDB 10.1 servers. The only difference is that this particular one is running on CentOS 6, while the others are on CentOS 7.

Oracle trigger error, 10g to 11g export

i am trying to export a 10g database to 11g and receieving error(execution completed with warning) at the row that tries to create the trigger.
--------------------------------------------------------
-- DDL for Trigger TR_INS_DATACARD
--------------------------------------------------------
CREATE OR REPLACE TRIGGER "AFTARSIV"."TR_INS_DATACARD" BEFORE INSERT ON fichas REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN SELECT fichas_seq.NEXTVAL INTO :NEW.clave FROM DUAL; END;
/
ALTER TRIGGER "AFTARSIV"."TR_INS_DATACARD" ENABLE;
SQL command works fine with 10g, it even creates the trigger at 11g but the trigger has this error:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ;

Resources