Skip to content

Instantly share code, notes, and snippets.

View aissam-en's full-sized avatar

Aissam EN-NAHEL aissam-en

View GitHub Profile
@aissam-en
aissam-en / check_postgresql_sequences_sync_status.sql
Created June 30, 2025 10:58
Postgresql : Detect If sequences are out of sync with table IDs (check if sequence is behind MAX(id))
-- SQL query to list all PostgreSQL sequences, their current last_value, and whether they are behind the maximum id in their corresponding tables.
-- Useful for debugging duplicate key errors caused by manual inserts or broken auto-increment.
SELECT
n.nspname AS schema,
c.relname AS sequence_name,
t.relname AS table_name,
a.attname AS column_name,
s.last_value,
(SELECT MAX(x) FROM (
@aissam-en
aissam-en / install_postgresql_ubuntu_server.md
Created August 7, 2024 12:05
install postgresql ubuntu server
  • install postgreSQL
sudo apt install postgresql
  • set password :
     sudo -u postgres psql template1
     ALTER USER postgres with encrypted password 'my_passwordy';
     \q
@aissam-en
aissam-en / Springboot_app_test_env.md
Last active August 7, 2024 12:13
Creating a Systemd Service for Spring Boot Application to run it in test environments

Create service file :

sudo nano /etc/systemd/system/my_app.service

The content of my_app.service file:

[Unit]
Description=Springboot app for BLABLA (test-env)
After=syslog.target network.target